Skip to content

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.

)


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).

from typing import Tuple

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