You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to type hints for a genetic input tuple, with list[T] map to T #2063
I think this is not ambiguous, but note that I'm relying on the fact that it's impossible (at least in CPython) to construct an object that is both an instance of int and an instance of str.
Activity
RBerga06 commentedon Aug 6, 2025
I believe this is not yet supported because in some cases it can be ambiguous. Given:
what should type checkers reveal for the following code?
There are two different options that are compatible with
func's signature but are not consistent with each other:The type checker infers:
Ts1=tuple[int]T=intTs2=tuple[list[str], float]tuple[int, int, list[str], float]The type checker infers:
Ts1=tuple[int, list[int]]T=strTs2=tuple[float]tuple[int, list[int], str, float]Actually, because
TypeVarTuples can also bind to empty tuples, I think this counterexample can be further simplified:See the Python Typing specification for another example of ambiguity with
TypeVarTuples.RBerga06 commentedon Aug 6, 2025
Maybe introducing
TypeVarTuplebounds could allow for multipleTypeVarTuples in the same type argument list?I think this is not ambiguous, but note that I'm relying on the fact that it's impossible (at least in CPython) to construct an object that is both an instance of
intand an instance ofstr.