Description
For this snippet:
class Iterator:
def __next__(self) -> int:
return 42
class Iterable:
def __iter__(self) -> Iterator | int:
return Iterator()
for x in Iterable():
pass
We currently emit this diagnostic:
error: lint:not-iterable
--> /Users/alexw/dev/experiment/foo.py:9:10
|
7 | return Iterator()
8 |
9 | for x in Iterable():
| ^^^^^^ Object of type `Iterable` is not iterable because its `__iter__` method is possibly unbound
10 | pass
|
It's correct for us to emit a diagnostic here. However, this is an incorrect error message: __iter__ here is definitely bound, but it returns an object that might not necessarily have a __next__ method.