-
Notifications
You must be signed in to change notification settings - Fork 3
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
DOC: Revision of docstrings in the iterators' module #29
DOC: Revision of docstrings in the iterators' module #29
Conversation
f29739a
to
539250c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #29 +/- ##
==========================================
+ Coverage 68.10% 68.24% +0.13%
==========================================
Files 20 20
Lines 994 995 +1
Branches 130 130
==========================================
+ Hits 677 679 +2
Misses 263 263
+ Partials 54 53 -1 ☔ View full report in Codecov by Sentry. |
There seems to be some conflicts after the style update I made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why the iter()
decoration to range, other than that looks good!
87fed5d
to
3ebda3a
Compare
Force pushed; conflicts gone. |
Add `None` to b-vals iterators `size` parameter annotations. Edit the parameter types accordingly in the docstrings and describe what happens when `None` is provided. Fixes: ``` src/nifreeze/utils.py:30: error: Incompatible default for argument "size" (default has type "None", argument has type "int") [assignment] src/nifreeze/utils.py:30: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True src/nifreeze/utils.py:30: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase src/nifreeze/utils.py:59: error: Incompatible default for argument "size" (default has type "None", argument has type "int") [assignment] src/nifreeze/utils.py:59: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True src/nifreeze/utils.py:59: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase src/nifreeze/utils.py:108: error: Incompatible default for argument "size" (default has type "None", argument has type "int") [assignment] src/nifreeze/utils.py:108: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True src/nifreeze/utils.py:108: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase src/nifreeze/utils.py:135: error: Incompatible default for argument "size" (default has type "None", argument has type "int") [assignment] src/nifreeze/utils.py:135: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True src/nifreeze/utils.py:135: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase ``` raised for example in: https://github.com/nipreps/nifreeze/actions/runs/12437972140/job/34728973936#step:8:32
Remove unused parameter from method `bvalue_iterator` prototype and docstring. Use the `*_` to denote unused arguments.
3ebda3a
to
8e7aba9
Compare
In 6398249, I have added the following changes:
In addition to those changes, I also rolled back the You can always convert these generators to iterators or lists at any moment. @jhlegarreta @effigies let me know if the above sounds reasonable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 6398249, I have added the following changes:
- Revert the removal of optional keyword arguments from docstrings. The rationale is that, if they are not documented there, the type hints in the signature are insufficient to introspect what keyword arguments may be provided and their behavior. As discussed above, you can use Other parameters for this as per numpydoc. However, in this particular case I find it overly verbose. Instead, I propose we explicitly label these arguments as optional, keyword argument.
Agreed that documenting these is useful in this case. Left a few style comment to make documenting these nicer/more Pythonin/Sphinxier if there is a way.
- Rewrite the Returns section with Yields, following numpydocs' documentation, as all these are meant to yield values rather than return values.
👍 Yield
looks the right thing.
In addition to those changes, I also rolled back the iter() decoration of the linear iterator, and replace it with an actual generator, for consistency with the other > iterators.
OK.
@jhlegarreta @effigies let me know if the above sounds reasonable.
Changes look OK. The only inconsistency is the _iterator
naming vs. them being generators.
Co-authored-by: Jon Haitz Legarreta Gorroño <jon.haitz.legarreta@gmail.com>
Let's then punt this inconsistency for the future, as the module is also called "iterators". They are indeed iterators (that's why the recommendation for the type hint of the return is Iterator), however they are not implemented exactly like proper Python iterators. If the naming is too irritating for you or anyone, happy to see a future PR addressing this. |
FIX: Test with a warning unhandled by #29
size
parameter annotationslinear_iterator
return an iteratorbvalue_iterator
prototype