Skip to content

Commit 78fcddb

Browse files
authored
Merge pull request #1409 from effigies/chore/precommit-autoupdate
chore: pre-commit autoupdate, address fresh typecheck errors
2 parents 9d66d8a + 813144e commit 78fcddb

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ repos:
1313
- id: check-merge-conflict
1414
- id: check-vcs-permalinks
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.9.1
16+
rev: v0.9.6
1717
hooks:
1818
- id: ruff
1919
args: [ --fix ]
2020
exclude: = ["doc", "tools"]
2121
- id: ruff-format
2222
exclude: = ["doc", "tools"]
2323
- repo: https://github.com/pre-commit/mirrors-mypy
24-
rev: v1.14.1
24+
rev: v1.15.0
2525
hooks:
2626
- id: mypy
2727
# Sync with project.optional-dependencies.typing
@@ -36,7 +36,7 @@ repos:
3636
args: ["nibabel"]
3737
pass_filenames: false
3838
- repo: https://github.com/codespell-project/codespell
39-
rev: v2.3.0
39+
rev: v2.4.1
4040
hooks:
4141
- id: codespell
4242
additional_dependencies:

.readthedocs.yaml

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ build:
99
- asdf plugin add uv
1010
- asdf install uv latest
1111
- asdf global uv latest
12-
# Turn `python -m virtualenv` into `python -c pass`
13-
- truncate --size 0 $( dirname $( uv python find ) )/../lib/python3*/site-packages/virtualenv/__main__.py
14-
post_create_environment:
12+
create_environment:
1513
- uv venv $READTHEDOCS_VIRTUALENV_PATH
16-
# Turn `python -m pip` into `python -c pass`
17-
- truncate --size 0 $( ls -d $READTHEDOCS_VIRTUALENV_PATH/lib/python3* )/site-packages/pip.py
18-
post_install:
14+
install:
1915
# Use a cache dir in the same mount to halve the install time
2016
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install --cache-dir $READTHEDOCS_VIRTUALENV_PATH/../../uv_cache .[doc]
2117
pre_build:
2218
- ( cd doc; python tools/build_modref_templates.py nibabel source/reference False )
19+
20+
sphinx:
21+
configuration: doc/source/conf.py

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/tests/test_proxy_api.py

+4
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def validate_array_interface_with_dtype(self, pmaker, params):
166166
assert_dt_equal(out.dtype, np.dtype(dtype))
167167
# Shape matches expected shape
168168
assert out.shape == params['shape']
169+
del out
170+
del direct
171+
172+
del orig
169173

170174
if context is not None:
171175
context.__exit__()

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)