Skip to content

Commit 07eeeaa

Browse files
committed
type: Address fresh complaints
1 parent cfa3180 commit 07eeeaa

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

nibabel/deprecated.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
from .pkg_info import cmp_pkg_version
1010

1111
if ty.TYPE_CHECKING:
12+
# PY39: ParamSpec is available in Python 3.10+
1213
P = ty.ParamSpec('P')
14+
else:
15+
# Just to keep the runtime happy
16+
P = ty.TypeVar('P')
1317

1418

1519
class ModuleProxy:
@@ -44,7 +48,7 @@ def __repr__(self) -> str:
4448
return f'<module proxy for {self._module_name}>'
4549

4650

47-
class FutureWarningMixin:
51+
class FutureWarningMixin(ty.Generic[P]):
4852
"""Insert FutureWarning for object creation
4953
5054
Examples

nibabel/nifti1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ class Nifti1Header(SpmAnalyzeHeader):
843843
single_magic = b'n+1'
844844

845845
# Quaternion threshold near 0, based on float32 precision
846-
quaternion_threshold = np.finfo(np.float32).eps * 3
846+
quaternion_threshold: np.floating = np.finfo(np.float32).eps * 3
847847

848848
def __init__(self, binaryblock=None, endianness=None, check=True, extensions=()):
849849
"""Initialize header from binary data block and extensions"""

nibabel/volumeutils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
DT = ty.TypeVar('DT', bound=np.generic)
3636

3737
sys_is_le = sys.byteorder == 'little'
38-
native_code = '<' if sys_is_le else '>'
39-
swapped_code = '>' if sys_is_le else '<'
38+
native_code: ty.Literal['<', '>'] = '<' if sys_is_le else '>'
39+
swapped_code: ty.Literal['<', '>'] = '>' if sys_is_le else '<'
4040

4141
_endian_codes = ( # numpy code, aliases
4242
('<', 'little', 'l', 'le', 'L', 'LE'),

0 commit comments

Comments
 (0)