Closed
Description
from typing import Generic, TypeVar
T = TypeVar('T')
class C(Generic[T]):
def foo(self, x: T) -> None:
if isinstance(x, int):
self.bar(x)
def bar(self, x: T) -> None:
pass
fails with Argument 1 to "bar" of "C" has incompatible type "int"; expected "T"
, even though x
is obviously a T
(that was its annotated type!)
Arguably this is just the Dreaded Intersection Bug (#3603) in a different manifestation?