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

[F811] Warn on and delete double import #275

Open
wants to merge 2 commits into
base: gh/"ansley"/5/base
Choose a base branch
from

Conversation

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

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
Member

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
Member

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
Member

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.

3 participants