Skip to content

Commit

Permalink
Tiny typing fix
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fmagin authored and mborgerson committed Jul 9, 2023
1 parent fd854f6 commit d0765c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cle/backends/regions.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit d0765c4

Please sign in to comment.