Skip to content
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

ENH: Fix type annotations in b-vals iterators #29

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jhlegarreta
Copy link
Contributor

@jhlegarreta jhlegarreta commented Dec 22, 2024

  • ENH: Add None to b-vals iterators size parameter annotations
  • ENH: Make linear_iterator return an iterator
  • ENH: Remove unused parameter form bvalue_iterator prototype

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
Make `linear_iterator` return an iterator: `range` is an iterable, so
call `iter` on `range` in order to return an iterator.

Fixes:
```
src/nifreeze/utils.py:56: error:
 Incompatible return value type (got "range", expected "Iterator[int]")  [return-value]
src/nifreeze/utils.py:56: note:
 "range" is missing following "Iterator" protocol member:
src/nifreeze/utils.py:56: note:
     __next__
```

raised for example in:
https://github.com/nipreps/nifreeze/actions/runs/12437972140/job/34728973936#step:8:35
@jhlegarreta jhlegarreta force-pushed the FixbvalIteratorsTypeAnnotations branch from f29739a to 539250c Compare December 22, 2024 01:07
Copy link

codecov bot commented Dec 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.84%. Comparing base (6b6ba70) to head (87fed5d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #29   +/-   ##
=======================================
  Coverage   65.84%   65.84%           
=======================================
  Files          18       18           
  Lines         931      931           
  Branches      119      119           
=======================================
  Hits          613      613           
  Misses        274      274           
  Partials       44       44           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Remove unused parameter from method `bvalue_iterator` prototype and
docstring. Use the `*_` to denote unused arguments.
@jhlegarreta jhlegarreta marked this pull request as ready for review December 22, 2024 01:20
@jhlegarreta
Copy link
Contributor Author

jhlegarreta commented Dec 22, 2024

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