Skip to content

Require first argument of namedtuple to match with variable name #9577

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

Merged
merged 11 commits into from
Oct 18, 2020

Conversation

momohatt
Copy link
Contributor

@momohatt momohatt commented Oct 11, 2020

Description

Closes #4589

This PR modifies check_namedtuple to return the internal name of the namedtuples (e.g. the content of the first argument of namedtuple/NamedTuple) so that the callers, especially analyze_namedtuple_assign, can check if the name of the variable on the l.h.s. matches with the first argument of the namedtuple.

Test Plan

Added a code snippet from #4589 as the new test.
Also, I deleted testReexportNamedTupleChange (which was added in #6698 for #6548 (comment)) since we wouldn't need to worry about this case when this is merged.

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks.

@msullivan msullivan merged commit 9165bb1 into python:master Oct 18, 2020
@momohatt momohatt deleted the fix-namedtuple branch October 18, 2020 02:27
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.

Check first argument of NamedTuple/namedtuple
2 participants