Skip to content

Commit 2532132

Browse files
committed
sty: Apply UP007, UP012
This is safe since we use from __future__ import annotations.
1 parent 276f786 commit 2532132

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

nibabel/nifti1.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,15 @@ class NiftiExtension(ty.Generic[T]):
325325
"""
326326

327327
code: int
328-
encoding: ty.Optional[str] = None
328+
encoding: str | None = None
329329
_content: bytes
330-
_object: ty.Optional[T] = None
330+
_object: T | None = None
331331

332332
def __init__(
333333
self,
334-
code: ty.Union[int, str],
334+
code: int | str,
335335
content: bytes = b'',
336-
object: ty.Optional[T] = None,
336+
object: T | None = None,
337337
) -> None:
338338
"""
339339
Parameters
@@ -565,9 +565,9 @@ class Nifti1DicomExtension(Nifti1Extension[DicomDataset]):
565565

566566
def __init__(
567567
self,
568-
code: ty.Union[int, str],
569-
content: ty.Union[bytes, DicomDataset, None] = None,
570-
parent_hdr: ty.Optional[Nifti1Header] = None,
568+
code: int | str,
569+
content: bytes | DicomDataset | None = None,
570+
parent_hdr: Nifti1Header | None = None,
571571
) -> None:
572572
"""
573573
Parameters

nibabel/tests/test_nifti1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ def test_extension_content_access():
12391239
assert ext.text == '123'
12401240

12411241
# Test that encoding errors are caught
1242-
ascii_ext = Nifti1Extension('comment', 'hôpital'.encode('utf-8'))
1242+
ascii_ext = Nifti1Extension('comment', 'hôpital'.encode())
12431243
ascii_ext.encoding = 'ascii'
12441244
with pytest.raises(UnicodeDecodeError):
12451245
ascii_ext.text

0 commit comments

Comments
 (0)