-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TypeVarTupleExpr node #12481
Add TypeVarTupleExpr node #12481
Conversation
This comment has been minimized.
This comment has been minimized.
@@ -2314,6 +2314,32 @@ def deserialize(cls, data: JsonDict) -> 'ParamSpecExpr': | |||
) | |||
|
|||
|
|||
class TypeVarTupleExpr(TypeVarLikeExpr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add docstring for this and also modify the docstring of TypeVarLikeExpr
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just left a few ideas further tests. Feel free to merge after you've updated tests.
|
||
TVariadic = TypeVarTuple('TVariadic') | ||
TP = TypeVarTuple('?') # E: String argument 1 "?" to TypeVarTuple(...) does not match variable name "TP" | ||
TP2: int = TypeVarTuple('TP2') # E: Cannot declare the type of a TypeVar or similar construct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test calling TypeVarTuple
with no args, too many args, and keyword args (all should be disallowed).
@@ -1451,3 +1451,10 @@ heterogenous_tuple: Tuple[Unpack[Tuple[int, str]]] | |||
homogenous_tuple: Tuple[Unpack[Tuple[int, ...]]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add at least one AST dump test case to test-data/unit/semanal-types.test
.
Also flake8 is failing. |
Yeah the flakr8 started falling when I updated the docstrings |
This adds minimal support for a TypeVarTupleExpr node, gated behind the flag to enable incomplete features. It is modeled after paramspec, including the part where we don't support the various arguments that have no behavior defined in PEP646. We also include TypeVarTuple in the typing_extensions stubs for test data and add some very basic semanal tests to verify the basic things work.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This adds minimal support for a TypeVarTupleExpr node, gated behind the
flag to enable incomplete features. It is modeled after paramspec,
including the part where we don't support the various arguments that
have no behavior defined in PEP646.
We also include TypeVarTuple in the typing_extensions stubs for test
data and add some very basic semanal tests to verify the basic things work.