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
Ts=TypeVarTuple('Ts')
defremove_first_element(tup: tuple[Any, *Ts]) ->tuple[*Ts]:
returntup[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.
The text was updated successfully, but these errors were encountered:
From the docs:
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.
The text was updated successfully, but these errors were encountered: