Open
Description
Here, in caller_bad
, immediately unpacking the result leads to the second type variable getting bound to int | str
instead of just int
from typing import TypeVar, Generic
T = TypeVar('T')
U = TypeVar('U')
class Test(Generic[T, U]):
pass
def test(gen: Test[T, U]) -> tuple[T, U | str]:
raise NotImplementedError
def call() -> Test[str, int]:
raise NotImplementedError
def caller_bad() -> None:
x, y = test(call())
def caller_ok() -> None:
res = test(call())
x, y = res
_bug.py:16: error: Argument 1 to "test" has incompatible type "Test[str, int]"; expected "Test[str, Union[int, str]]" [arg-type]