-
Notifications
You must be signed in to change notification settings - Fork 65
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
base: gh/"ansley"/5/base
Are you sure you want to change the base?
The head ref may contain hidden characters: "gh/\"ansley\"/5/head"
Conversation
[ghstack-poisoned]
[ghstack-poisoned]
expected_replacement=""" | ||
import a | ||
""", |
There was a problem hiding this comment.
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.
import a, b | ||
""", |
There was a problem hiding this comment.
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.
import a, b | ||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
from x import a | ||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Stack from ghstack (oldest at bottom):
pyflakes
directory #271