Description
Steps to reproduce
Starting from astroid 2.5.7, I'm seeing false not-an-iterable when generator class methods are annotated with @overload
.
from typing import overload, Iterator
class MyClass:
@overload
def transitions(self, foo: int, bar: int) -> Iterator[int]: ...
@overload
def transitions(self, baz: str) -> Iterator[str]: ...
def transitions(self, foo_or_baz, bar=None):
yield
for _ in MyClass().transitions('hello'):
pass
If @overload
is removed, or the function is moved to the module level, or I switch to astroid 2.5.6, the problem goes away.
It happens with pylint-2.8.3 or pylint-3.0.0a3.
Current behavior
E1133: Non-iterable value MyClass().transitions('hello') is used in an iterating context (not-an-iterable)
Expected behavior
no error