Skip to content

STYLE: Fix type checking errors in volumeutils.rec2dict #1424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.33%. Comparing base (b5ecf48) to head (1ed2b6c).

Files with missing lines Patch % Lines
nibabel/volumeutils.py 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1424      +/-   ##
==========================================
- Coverage   95.34%   95.33%   -0.01%     
==========================================
  Files         209      209              
  Lines       29780    29783       +3     
  Branches     3357     3358       +1     
==========================================
+ Hits        28393    28394       +1     
- Misses        948      949       +1     
- Partials      439      440       +1     

☔ 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.

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.

1 participant