Open
Description
When returning a value that fits within the typevar constraint, the checker returns an Incompatible return type [7]
error. To reproduce:
T = TypeVar("T", int, str)
def fn(value: T) -> T:
if isinstance(value, int):
return int(5)
else:
return str("five")
This raises Incompatible return type [7]: Expected Variable[T <: [int, str]] but got int
and Incompatible return type [7]: Expected Variable[T <: [int, str]] but got str
This works correctly:
def fn(value: T) -> T:
return value