nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
649 stars 258 forks source link

TYP: Annotate loadsave and image header classes #1213

Closed effigies closed 1 year ago

effigies commented 1 year ago

nb.load() and (to some extent) nb.save() are probably the most used functions. They should have some signatures, though the usefulness is bounded as the type checker can't infer the resulting type from the filename.

While testing this on a code base I'm writing to be type-checked from the start, I found that everything declared itself as having a FileBasedHeader, which is not very useful. I can't come up with something type-variable-ish so that we can deduplicate these and rely on the header_class, but oh well.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 94.28% and no project coverage change.

Comparison is base (40e31e8) 92.16% compared to head (9f189c6) 92.16%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1213 +/- ## ======================================= Coverage 92.16% 92.16% ======================================= Files 98 98 Lines 12366 12372 +6 Branches 2545 2543 -2 ======================================= + Hits 11397 11403 +6 Misses 646 646 Partials 323 323 ``` | [Impacted Files](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy) | Coverage Δ | | |---|---|---| | [nibabel/nifti1.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9uaWZ0aTEucHk=) | `92.76% <50.00%> (ø)` | | | [nibabel/analyze.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9hbmFseXplLnB5) | `98.59% <100.00%> (ø)` | | | [nibabel/brikhead.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9icmlraGVhZC5weQ==) | `97.51% <100.00%> (+0.01%)` | :arrow_up: | | [nibabel/cifti2/cifti2.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9jaWZ0aTIvY2lmdGkyLnB5) | `96.86% <100.00%> (+<0.01%)` | :arrow_up: | | [nibabel/ecat.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9lY2F0LnB5) | `88.21% <100.00%> (ø)` | | | [nibabel/filebasedimages.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9maWxlYmFzZWRpbWFnZXMucHk=) | `97.29% <100.00%> (-0.04%)` | :arrow_down: | | [nibabel/freesurfer/mghformat.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9mcmVlc3VyZmVyL21naGZvcm1hdC5weQ==) | `95.08% <100.00%> (+0.02%)` | :arrow_up: | | [nibabel/imageclasses.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9pbWFnZWNsYXNzZXMucHk=) | `100.00% <100.00%> (ø)` | | | [nibabel/loadsave.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9sb2Fkc2F2ZS5weQ==) | `70.53% <100.00%> (-0.77%)` | :arrow_down: | | [nibabel/minc1.py](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy#diff-bmliYWJlbC9taW5jMS5weQ==) | `90.36% <100.00%> (ø)` | | | ... and [5 more](https://codecov.io/gh/nipy/nibabel/pull/1213?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nipy)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.