Skip to content

Conversation

jhlegarreta
Copy link
Contributor

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:22

Copy link

codecov bot commented Jul 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.43%. Comparing base (b5ecf48) to head (bfaa984).
⚠️ Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1424      +/-   ##
==========================================
+ Coverage   95.34%   95.43%   +0.09%     
==========================================
  Files         209      209              
  Lines       29780    29784       +4     
  Branches     3357     4472    +1115     
==========================================
+ Hits        28393    28425      +32     
+ Misses        948      926      -22     
+ Partials      439      433       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhlegarreta jhlegarreta force-pushed the FixTypecheckErrors branch from fa614ce to 0e7f41c Compare July 5, 2025 22:27
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:22
@jhlegarreta jhlegarreta force-pushed the FixTypecheckErrors branch from 0e7f41c to 1ed2b6c Compare July 5, 2025 22:41
@jhlegarreta
Copy link
Contributor Author

@effigies This is ready to be merged.

@effigies effigies merged commit d8160e2 into nipy:master Sep 19, 2025
57 of 58 checks passed
@jhlegarreta jhlegarreta deleted the FixTypecheckErrors branch September 19, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants