Closed
Description
From the docs:
Ts = TypeVarTuple('Ts')
def remove_first_element(tup: tuple[Any, *Ts]) -> tuple[*Ts]:
return tup[1:]
# Ts is bound to ()
# Return value is (), which has type tuple[()]
remove_first_element(tup=(1,))
# Ts is bound to (str,)
# Return value is ('spam',), which has type tuple[str]
remove_first_element(tup=(1, 'spam'))
# Ts is bound to (str, float)
# Return value is ('spam', 3.0), which has type tuple[str, float]
remove_first_element(tup=(1, 'spam', 3.0))
Notice that "T" is only used once in the function signature, which Pylance will highlight as an error.
In this case, Any is just as meaningful as T (and I would argue semantically better, we don't care what the first element is)
All of the examples (checked with reveal_type) are still valid.