Sample:
class Some:
def __getitem__(self, i: int) -> str:
if i >= 2:
raise IndexError()
return chr(97 + i)
s = Some()
for x in s: # error here
print(x)
Output:
» mypy out/ex.py --strict-optional --warn-unreachable --show-traceback
out/ex.py:10: error: "Some" has no attribute "__iter__" (not iterable)
But, in runtime it works just fine:
Docs: https://pyneng.readthedocs.io/en/latest/book/23_oop_special_methods/iterable_iterator.html#iteration-protocol
I will try to send a PR soon!
Sample:
Output:
But, in runtime it works just fine:
Docs: https://pyneng.readthedocs.io/en/latest/book/23_oop_special_methods/iterable_iterator.html#iteration-protocol
I will try to send a PR soon!