*Ts syntax in type comments #1452
Answered
by
erictraut
superbobry
asked this question in
Q&A
|
Is it valid to use the as if it was ? |
Answered by
erictraut
Aug 23, 2023
Replies: 1 comment 1 reply
|
Type comments have been deprecated for a long time. They are still (partially) supported by some type checkers for old code that needs to remain compatible with Python 2, but you shouldn't be using them for new code. If you want to use from typing_extensions import Unpack, TypeVarTuple
Ts = TypeVarTuple("Ts")
def f(*args: Unpack[Ts]) -> Unpack[Ts]:
... |
1 reply
Answer selected by
superbobry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Type comments have been deprecated for a long time. They are still (partially) supported by some type checkers for old code that needs to remain compatible with Python 2, but you shouldn't be using them for new code.
TypeVarTupleis a relatively new feature, so I wouldn't expect tools to support this with type comments.If you want to use
TypeVarTuplewith a version of Python prior to 3.11, you can usetyping_extensions.Unpack.