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

Restrict type of AssignmentExpr.target to NameExpr #18714

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bzoracler
Copy link
Contributor

Assignment expression targets can only be identifiers. From the grammar:

assignment_expression:
    | NAME ':=' ~ expression 

This corresponds to the standard library AST node's target type:

class NamedExpr(expr):
    if sys.version_info >= (3, 10):
        __match_args__ = ("target", "value")
    target: Name

@bzoracler bzoracler marked this pull request as draft February 20, 2025 22:44
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@bzoracler bzoracler marked this pull request as ready for review February 20, 2025 23:15
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.

1 participant