Commit 0e7f41c
committed
STYLE: Fix type checking errors in
Fix type checking errors in `volumeutils.rec2dict`:
- Ensure that the recarray is iterable; return immediately if no fields
are found.
- Accomodate `Any` type in return the dictionary type
Fixes:
```
nibabel/volumeutils.py:1391: error:
Item "None" of "MappingProxyType[str, tuple[dtype[Any], int] | tuple[dtype[Any], int, Any]] | None"
has no attribute "__iter__" (not iterable) [union-attr]
```
and
```
nibabel/volumeutils.py:1398: error:
Incompatible return value type (got "dict[str | Any, ndarray[tuple[Any, ...], dtype[Any]]]",
expected "dict[str, generic[Any] | ndarray[tuple[Any, ...], dtype[Any]]]") [return-value]
nibabel/volumeutils.py:1398: note: Perhaps you need a type annotation for "dct"?
Suggestion: "dict[str, generic[Any] | ndarray[tuple[Any, ...], dtype[Any]]]"
```
raised for example in:
https://github.com/nipy/nibabel/actions/runs/16092302666/job/45410655458?pr=1422#step:7:22volumeutils.rec2dict
1 parent b5ecf48 commit 0e7f41c
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
1365 | 1366 | | |
1366 | 1367 | | |
1367 | 1368 | | |
1368 | | - | |
| 1369 | + | |
1369 | 1370 | | |
1370 | 1371 | | |
1371 | 1372 | | |
| |||
1388 | 1389 | | |
1389 | 1390 | | |
1390 | 1391 | | |
| 1392 | + | |
| 1393 | + | |
1391 | 1394 | | |
1392 | 1395 | | |
1393 | 1396 | | |
| |||
0 commit comments