From d0765c41cb8aa7467b274600568c68efd4f46a5e Mon Sep 17 00:00:00 2001 From: Florian Magin Date: Thu, 6 Jul 2023 15:58:26 +0200 Subject: [PATCH] Tiny typing fix The Regions class is implicitly iterable because it defines __len__ and __getitem__. Mypy doesn't like this, and the recommendation seems to be to just make __iter__ explicit: https://stackoverflow.com/a/61739436/13220684 --- cle/backends/regions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cle/backends/regions.py b/cle/backends/regions.py index 97a59ee6..27fa8a72 100644 --- a/cle/backends/regions.py +++ b/cle/backends/regions.py @@ -1,4 +1,4 @@ -from typing import Generic, List, Optional, TypeVar +from typing import Generic, Iterator, List, Optional, TypeVar from cle.utils import key_bisect_find, key_bisect_insort_left @@ -57,6 +57,9 @@ def __setitem__(self, idx: int, item: R) -> None: # update self._sorted_list self._sorted_list = self._make_sorted(self._list) + def __iter__(self) -> Iterator[R]: + return iter(self._list) + def __len__(self) -> int: return len(self._list)