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

[ExpressionContextProvider] Make subscript values have a LOAD context #319

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

zsol
Copy link
Member

@zsol zsol commented Jun 18, 2020

Fixes #318.

Summary

This brings LibCST in line with the built in ast module.

Test Plan

Changed/added tests + manually verified the following file is not touched by the remove unused imports codemod:

from a import b
b[0] = False
python -m libcst.tool codemod remove_unused_imports.RemoveUnusedImportsCommand test.py -u

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2020
@zsol zsol requested a review from jimmylai June 18, 2020 14:13
Copy link
Contributor

@jimmylai jimmylai left a comment

Choose a reason for hiding this comment

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

This PR is awesome. It identified and fixed the issue correctly.
Given a subscript e.g.b[0] = False
The name b should have LOAD context and only the subscript b[0] has the STORE context.

@jimmylai jimmylai merged commit 73608ad into Instagram:master Jun 18, 2020
@zsol zsol deleted the subscript-value-expressioncontext branch June 18, 2020 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Names in subscript expressions have the wrong expression context
3 participants