From f29739a00cb2efc16e9ab53a6200d69511d38a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sat, 21 Dec 2024 20:01:31 -0500 Subject: [PATCH] ENH: Make `linear_iterator` return an iterator 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 --- src/nifreeze/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nifreeze/utils.py b/src/nifreeze/utils.py index cdb785b..5e27d22 100644 --- a/src/nifreeze/utils.py +++ b/src/nifreeze/utils.py @@ -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]: