Bug Report, To Reproduce, and Actual Behaviour
Mypy rejects this example (see the line containing reveal_type(f(b)))
# mypy: disable-error-code=empty-body
type VarTuple[T] = tuple[T, ...]
class MyTuple(tuple[int, str]): ...
def f[T: str | MyTuple](arg: T | VarTuple[T], /) -> T: ...
def f2[T: MyTuple](arg: T | VarTuple[T], /) -> T: ...
b = MyTuple((1, ""))
reveal_type(f(b)) # E: Argument 1 to "f" has incompatible type "MyTuple"; expected "tuple[Never, ...]" [arg-type] \
# N: Revealed type is "Never"
reveal_type(f2(b)) # N: Revealed type is "tuple[int, str, fallback=__main__.MyTuple]"
Expected Behavior
No errors and revealed type for f(b) should be same as for f2(b).
Your Environment
Bug Report, To Reproduce, and Actual Behaviour
Mypy rejects this example (see the line containing
reveal_type(f(b)))Expected Behavior
No errors and revealed type for
f(b)should be same as forf2(b).Your Environment