Skip to content

Conversation

Comment on lines +197 to +199
expected_replacement="""
import a
""",
Copy link
Collaborator

Choose a reason for hiding this comment

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

For these shadowed imports, this autofix is incorrect — it will result in different runtime behavior than what the original code was, because the last import of a name overwrites all previous imports of that name.

If we can't get that right, then we need to skip the autofix, or defer this rule until a future time when we can do it correctly.

Comment on lines +176 to +177
import a, b
""",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know in this case, both a imports are referring to the same module, but I don't like the idea that we're removing the second import. We should instead be removing the first one, so that we're giving consistent runtime behavior before/after. For imports with side-effects, order unfortunately matters.

Comment on lines +185 to +186
import a, b
""",
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

Comment on lines +207 to +208
from x import a
""",
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

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. lint rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants