Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ 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 ]
exclude: = ["doc", "tools"]
- 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
Expand All @@ -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:
Expand Down
11 changes: 5 additions & 6 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion nibabel/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -44,7 +48,7 @@ def __repr__(self) -> str:
return f'<module proxy for {self._module_name}>'


class FutureWarningMixin:
class FutureWarningMixin(ty.Generic[P]):
"""Insert FutureWarning for object creation

Examples
Expand Down
2 changes: 1 addition & 1 deletion nibabel/nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
4 changes: 4 additions & 0 deletions nibabel/tests/test_proxy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand Down
4 changes: 2 additions & 2 deletions nibabel/volumeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down