from typing import Literal
def f(x: int | None = None, y: str = ""): ...
def _(flag: bool):
args = () if flag else (1,)
f(*args)
We error on f(*args) because args is a union of two fixed-length tuple types, so we give up and just treat it as a variable-length homogeneous iterable. (Pyright and pyrefly do the same.) But mypy allows this call. It would require expanding the union and checking the call twice, similar to how we do in overload matching.
We error on
f(*args)becauseargsis a union of two fixed-length tuple types, so we give up and just treat it as a variable-length homogeneous iterable. (Pyright and pyrefly do the same.) But mypy allows this call. It would require expanding the union and checking the call twice, similar to how we do in overload matching.