Skip to content

Commit

Permalink
ENH: Make linear_iterator return an iterator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jhlegarreta committed Dec 22, 2024
1 parent e813b66 commit f29739a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nifreeze/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def linear_iterator(size: int | None = None, **kwargs) -> Iterator[int]:
if size is None:
raise TypeError("Cannot build iterator without size")

return range(size)
return iter(range(size))


def random_iterator(size: int | None = None, **kwargs) -> Iterator[int]:
Expand Down

0 comments on commit f29739a

Please sign in to comment.