Skip to content
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

Merged
merged 1 commit into from
Apr 20, 2022
Merged

Add TypeVarTupleExpr node #12481

merged 1 commit into from
Apr 20, 2022

Conversation

jhance
Copy link
Collaborator

@jhance jhance commented Mar 28, 2022

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.

@jhance jhance changed the title Typevartuple Add TypeVarTupleExpr node Mar 28, 2022
@github-actions

This comment has been minimized.

@@ -2314,6 +2314,32 @@ def deserialize(cls, data: JsonDict) -> 'ParamSpecExpr':
)


class TypeVarTupleExpr(TypeVarLikeExpr):
Copy link
Collaborator

@97littleleaf11 97littleleaf11 Mar 28, 2022

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

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

Copy link
Collaborator

@JukkaL JukkaL left a 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
Copy link
Collaborator

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, ...]]]
Copy link
Collaborator

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.

@JukkaL
Copy link
Collaborator

JukkaL commented Mar 29, 2022

Also flake8 is failing.

@jhance
Copy link
Collaborator Author

jhance commented Mar 29, 2022

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.
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JukkaL JukkaL merged commit 50213b5 into python:master Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants