Skip to content

Commit

Permalink
sty: Apply UP007, UP012
Browse files Browse the repository at this point in the history
This is safe since we use from __future__ import annotations.
  • Loading branch information
effigies committed Sep 24, 2024
1 parent 276f786 commit 2532132
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions nibabel/nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ class NiftiExtension(ty.Generic[T]):
"""

code: int
encoding: ty.Optional[str] = None
encoding: str | None = None
_content: bytes
_object: ty.Optional[T] = None
_object: T | None = None

def __init__(
self,
code: ty.Union[int, str],
code: int | str,
content: bytes = b'',
object: ty.Optional[T] = None,
object: T | None = None,
) -> None:
"""
Parameters
Expand Down Expand Up @@ -565,9 +565,9 @@ class Nifti1DicomExtension(Nifti1Extension[DicomDataset]):

def __init__(
self,
code: ty.Union[int, str],
content: ty.Union[bytes, DicomDataset, None] = None,
parent_hdr: ty.Optional[Nifti1Header] = None,
code: int | str,
content: bytes | DicomDataset | None = None,
parent_hdr: Nifti1Header | None = None,
) -> None:
"""
Parameters
Expand Down
2 changes: 1 addition & 1 deletion nibabel/tests/test_nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ def test_extension_content_access():
assert ext.text == '123'

# Test that encoding errors are caught
ascii_ext = Nifti1Extension('comment', 'hôpital'.encode('utf-8'))
ascii_ext = Nifti1Extension('comment', 'hôpital'.encode())
ascii_ext.encoding = 'ascii'
with pytest.raises(UnicodeDecodeError):
ascii_ext.text
Expand Down

0 comments on commit 2532132

Please sign in to comment.