This happens when using a class whose behavior depends on a constrained TypeVar. It seems that it naively uses the first overload when inferring the type of iter(obj). There's also a false positive when checking compatibility with Iterable, I guess it just tests if some overload matches?
For reference, pyright is fine with all the assert_type statements and catches the false positives, but complains about "Overloaded implementation is not consistent with signature"...
This happens when using a class whose behavior depends on a constrained
TypeVar
. It seems that it naively uses the first overload when inferring the type ofiter(obj)
. There's also a false positive when checking compatibility withIterable
, I guess it just tests if some overload matches?https://mypy-play.net/?mypy=master&python=3.11&gist=bbcb8287aa58a4aceea4063c27c92e2e