-
Notifications
You must be signed in to change notification settings - Fork 127
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
Add type annotations #656
Add type annotations #656
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #656 +/- ##
==========================================
+ Coverage 81.48% 81.87% +0.39%
==========================================
Files 41 41
Lines 3899 4116 +217
==========================================
+ Hits 3177 3370 +193
- Misses 722 746 +24
☔ View full report in Codecov by Sentry. |
I just merged a small PR which introduced conflicts, please resolve. |
83f86c4
to
dcabd66
Compare
@nipy/team-heudiconv I am currently facing the following blockers to applying type annotations:
Explanation for why
Therefore, the |
@nipy/team-heudiconv Also, side question: In this code: heudiconv/heudiconv/tests/test_dicoms.py Lines 30 to 33 in 2c6d228
is |
@nipy/team-heudiconv Yet another issue: In the following code: Lines 711 to 717 in 2c6d228
the
Exactly what type is |
@nipy/team-heudiconv This should hopefully be the last typing issue I post: The |
@yarikoptic I still need a resolution for the issues mentioned in my top comment. |
ATM it seems that no shipped along heuristic defines custom
and it is somewhat documented at https://heudiconv.readthedocs.io/en/latest/heuristics.html?highlight=grouping#grouping-string-or-grouping-files-dcmfilter-seqinfo and was introduced in #359 . The expectation is that if that is the callable - we get the same
I think the docstring overspecified and it should be just a
example.py also has an explicit |
@yarikoptic Specifying that the |
but it seems that we can't know them statically and moreover we "violate" it in case of |
FWIW -- just checked that it would not be a solution since then code which calls |
since we would need just 1 value to %s!
…ere just number to be used Not sure if that heuristic is even usable any longer, since no tests for it were done etc.
I've tuned up that
and |
hm, on CI (where we have py 3.7) it still fails with following
may be we just should go to newer python for type checking? |
read/write config - we know it must be dict age - must be str or float, as we test, the rest -- not legit
apparently treat_age would have made None into "None" string which maybe_na would not map to n/a. So decided to make it more explicit and specific here. I checked on sample that we do get even time as "str" from dcmdata, so should be matching
@jwodder please check two last small commits where I have (I think) constrained typing a little more - let me know if may be you have reservations against that. |
ok -- Let's go. Thank you again @jwodder for all this monumental work! |
although indeed |
🚀 PR was released in |
Closes #653.
Problems encountered so far with applying type annotations:
heudiconv.dicoms.group_dicoms_into_seqinfos()
: Ifgrouping == "custom"
andcustom_grouping
is a callable, the return value is the result of applyingcustom_grouping()
to some arguments; otherwise, the return value is something else. Normally, this could be annotated by using overloads andLiteral["custom"]
, but whenevergroup_dicoms_into_seqinfos()
is called in the heudiconv code,grouping
(if present) is always passed as a variable rather than a string literal, and soLiteral
is unusable here.heudiconv.dicoms.create_seqinfo()
states that the first argument is of typenibabel.nicom.dicomwrappers.MosaicWrapper
, yet here the supplied argument (obtained fromvalidate_dicom()
) is just anibabel.nicom.dicomwrappers.Wrapper
.SeqInfo.series_id
is clearly meant to be astr
, yet there are several places inheudiconv/heuristics/example.py
where this field is compared against or assigned to anint
variable.