This is similar to #14811, but still reproduces on master following bed49ab:
from typing import TypeVar
T = TypeVar("T")
class Foo:
count: int
def __init__(self) -> None:
self.count = 0
def __iter__(self: T) -> T:
return self
def __next__(self) -> int:
self.count += 1
if self.count > 3:
raise StopIteration
return self.count
a, b, c = Foo()
reveal_type(a) # note: Revealed type is "Any"
Mypy should have enough information here to infer that the type of a is int.
Mypy versions tested on