diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aefad8f42..2e6c466f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-merge-conflict - id: check-vcs-permalinks - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.1 + rev: v0.9.6 hooks: - id: ruff args: [ --fix ] @@ -21,7 +21,7 @@ repos: - id: ruff-format exclude: = ["doc", "tools"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.14.1 + rev: v1.15.0 hooks: - id: mypy # Sync with project.optional-dependencies.typing @@ -36,7 +36,7 @@ repos: args: ["nibabel"] pass_filenames: false - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell additional_dependencies: diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 0115c087b..1b2c53117 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,14 +9,13 @@ build: - asdf plugin add uv - asdf install uv latest - asdf global uv latest - # Turn `python -m virtualenv` into `python -c pass` - - truncate --size 0 $( dirname $( uv python find ) )/../lib/python3*/site-packages/virtualenv/__main__.py - post_create_environment: + create_environment: - uv venv $READTHEDOCS_VIRTUALENV_PATH - # Turn `python -m pip` into `python -c pass` - - truncate --size 0 $( ls -d $READTHEDOCS_VIRTUALENV_PATH/lib/python3* )/site-packages/pip.py - post_install: + install: # Use a cache dir in the same mount to halve the install time - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install --cache-dir $READTHEDOCS_VIRTUALENV_PATH/../../uv_cache .[doc] pre_build: - ( cd doc; python tools/build_modref_templates.py nibabel source/reference False ) + +sphinx: + configuration: doc/source/conf.py diff --git a/nibabel/deprecated.py b/nibabel/deprecated.py index 15d3e5326..d39c0624d 100644 --- a/nibabel/deprecated.py +++ b/nibabel/deprecated.py @@ -9,7 +9,11 @@ from .pkg_info import cmp_pkg_version if ty.TYPE_CHECKING: + # PY39: ParamSpec is available in Python 3.10+ P = ty.ParamSpec('P') +else: + # Just to keep the runtime happy + P = ty.TypeVar('P') class ModuleProxy: @@ -44,7 +48,7 @@ def __repr__(self) -> str: return f'' -class FutureWarningMixin: +class FutureWarningMixin(ty.Generic[P]): """Insert FutureWarning for object creation Examples diff --git a/nibabel/nifti1.py b/nibabel/nifti1.py index d012e6b95..5ea3041fc 100644 --- a/nibabel/nifti1.py +++ b/nibabel/nifti1.py @@ -843,7 +843,7 @@ class Nifti1Header(SpmAnalyzeHeader): single_magic = b'n+1' # Quaternion threshold near 0, based on float32 precision - quaternion_threshold = np.finfo(np.float32).eps * 3 + quaternion_threshold: np.floating = np.finfo(np.float32).eps * 3 def __init__(self, binaryblock=None, endianness=None, check=True, extensions=()): """Initialize header from binary data block and extensions""" diff --git a/nibabel/tests/test_proxy_api.py b/nibabel/tests/test_proxy_api.py index ba0f784d5..c5f7ab42a 100644 --- a/nibabel/tests/test_proxy_api.py +++ b/nibabel/tests/test_proxy_api.py @@ -166,6 +166,10 @@ def validate_array_interface_with_dtype(self, pmaker, params): assert_dt_equal(out.dtype, np.dtype(dtype)) # Shape matches expected shape assert out.shape == params['shape'] + del out + del direct + + del orig if context is not None: context.__exit__() diff --git a/nibabel/volumeutils.py b/nibabel/volumeutils.py index 700579a2e..cf23d905f 100644 --- a/nibabel/volumeutils.py +++ b/nibabel/volumeutils.py @@ -35,8 +35,8 @@ DT = ty.TypeVar('DT', bound=np.generic) sys_is_le = sys.byteorder == 'little' -native_code = '<' if sys_is_le else '>' -swapped_code = '>' if sys_is_le else '<' +native_code: ty.Literal['<', '>'] = '<' if sys_is_le else '>' +swapped_code: ty.Literal['<', '>'] = '>' if sys_is_le else '<' _endian_codes = ( # numpy code, aliases ('<', 'little', 'l', 'le', 'L', 'LE'),