nipy / nibabel

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

WIP: generalize class for opening image #1314

Open matthew-brett opened 3 months ago

matthew-brett commented 3 months ago

Allow FileHolder subclasses to change the ImageOpener class.

I wanted to do this to work with the fsspec file objects.

But - I couldn't see immediately what the right way to do the type checking is

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.26%. Comparing base (c445edd) to head (251c899).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1314 +/- ## ======================================= Coverage 92.26% 92.26% ======================================= Files 99 99 Lines 12472 12473 +1 Branches 2566 2566 ======================================= + Hits 11507 11508 +1 Misses 642 642 Partials 323 323 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

effigies commented 2 months ago
  • I was considering using OpenDef from openers.py, but that is only defined if ty.TYPE_CHECKING is True. I'd love some advice!

We could pull that out of the ty.TYPE_CHECKING block. The main point of putting it in there is that it was only used internally and it didn't seem usable at runtime. If you're also only using it as a type annotation, then it will be available to import into other modules like:

if ty.TYPE_CHECKING:
    from nibabel.openers import OpenerDef