Skip to content

Commit 83eaf0b

Browse files
authored
Merge pull request #1346 from effigies/fix/minmax-types
TYP: Address some recent numpy/mypy type complaints
2 parents f3c2168 + e2fe190 commit 83eaf0b

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.pre-commit-config.yaml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exclude: ".*/data/.*"
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v4.6.0
55
hooks:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
@@ -13,15 +13,18 @@ repos:
1313
- id: check-merge-conflict
1414
- id: check-vcs-permalinks
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.3.4
16+
rev: v0.6.4
1717
hooks:
1818
- id: ruff
19-
args: [--fix, --show-fixes, --exit-non-zero-on-fix]
19+
args: [ --fix ]
2020
exclude: = ["doc", "tools"]
2121
- id: ruff-format
2222
exclude: = ["doc", "tools"]
23+
- id: ruff
24+
args: [ --select, ISC001, --fix ]
25+
exclude: = ["doc", "tools"]
2326
- repo: https://github.com/pre-commit/mirrors-mypy
24-
rev: v1.5.1
27+
rev: v1.11.2
2528
hooks:
2629
- id: mypy
2730
# Sync with project.optional-dependencies.typing
@@ -36,7 +39,7 @@ repos:
3639
args: ["nibabel"]
3740
pass_filenames: false
3841
- repo: https://github.com/codespell-project/codespell
39-
rev: v2.2.6
42+
rev: v2.3.0
4043
hooks:
4144
- id: codespell
4245
additional_dependencies:

nibabel/pointset.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ def dim(self) -> int:
101101
"""The dimensionality of the space the coordinates are in"""
102102
return self.coordinates.shape[1] - self.homogeneous
103103

104-
def __rmatmul__(self, affine: np.ndarray) -> Self:
104+
# Use __rmatmul__ to prefer to compose affines. Mypy does not like that
105+
# this conflicts with ndarray.__matmul__. We will need some more feedback
106+
# on how this plays out for type-checking or code suggestions before we
107+
# can do better than ignore.
108+
def __rmatmul__(self, affine: np.ndarray) -> Self: # type: ignore[misc]
105109
"""Apply an affine transformation to the pointset
106110
107111
This will return a new pointset with an updated affine matrix only.

nibabel/volumeutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ def array_to_file(
624624
# pre scale thresholds
625625
mn, mx = _dt_min_max(in_dtype, mn, mx)
626626
mn_out, mx_out = _dt_min_max(out_dtype)
627-
pre_clips = max(mn, mn_out), min(mx, mx_out)
627+
pre_clips = max(mn, mn_out), min(mx, mx_out) # type: ignore[type-var]
628628
return _write_data(data, fileobj, out_dtype, order, pre_clips=pre_clips)
629629
# In any case, we do not want to check for nans because we've already
630630
# disallowed scaling that generates nans

0 commit comments

Comments
 (0)