Replies: 2 comments 1 reply
-
The problem is that if a type such as def func(*a: *tuple[*Ts, *Ts2]) -> Union[*Ts, *Ts2]:
...
func(1, 2, 3, 4) |
Beta Was this translation helpful? Give feedback.
-
This is a valid when using # Matches `func(1, "a", "b", ...)
@overload
def func(arg: int, *args: str): ...
# Matches `func("a", "b", ..., 1)
@overload
def func(*args: *tuple[*tuple[str, ...], int]): ...
# Matches `func("a", "b", ..., 1, "a", "b", ...), but not valid currently
@overload
def func(*args: *tuple[*tuple[str, ...], int, *tuple[str, ...]]): ... |
Beta Was this translation helpful? Give feedback.
-
PEP 646 says that you cannot unpack multiple
TypeVarTuples
at once, but i cant think of any reason for this limitation, there shouldn't be any ambiguity in it like with having multiple variadic generics which what the reason links to.A simple use-case for this is combining tuples together:
Another language with variadic generics is C++ which does support this:
Beta Was this translation helpful? Give feedback.
All reactions