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

feat: Add support for PEP646 syntax for unpacking TypeVarTuple #183

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

Daverball
Copy link
Collaborator

Closes #182

@Daverball Daverball requested a review from sondrelg January 17, 2024 08:36
Comment on lines +100 to +101
elif isinstance(node, ast.Starred) and isinstance(node.ctx, ast.Load):
self.visit(node.value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to suggest we'd support this syntax on all Python versions. Is that intentional?

Copy link
Collaborator Author

@Daverball Daverball Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's the same rationale as with supporting | on earlier versions, invalid runtime uses will already be detected by type checkers and inside string annotations (i.e. also in regular annotations when you use from __future__ import annotations) it's legal to use future syntax.

In the case of starred expressions most(all?) uses in type expressions are actually invalid syntax prior to 3.11, so we have to worry even less. (Otherwise the use of this syntax could've been backported to earlier versions, since TypeVarTuple itself was backported via typing-extensions)

Copy link
Member

@sondrelg sondrelg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👌

@Daverball Daverball merged commit 7b74e82 into main Jan 29, 2024
6 checks passed
@Daverball Daverball deleted the pep646-starred-unpack branch January 29, 2024 08:45
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.

Fully support PEP646
2 participants