Skip to content

*Ts syntax in type comments #1452

Answered by erictraut
superbobry asked this question in Q&A
Discussion options

You must be logged in to vote

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. TypeVarTuple is a relatively new feature, so I wouldn't expect tools to support this with type comments.

If you want to use TypeVarTuple with a version of Python prior to 3.11, you can use typing_extensions.Unpack.

from typing_extensions import Unpack, TypeVarTuple

Ts = TypeVarTuple("Ts")

def f(*args: Unpack[Ts]) -> Unpack[Ts]:
    ...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@superbobry
Comment options

Answer selected by superbobry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants