Remove shadowed import, rather than shadowing import, in F811#10388
Closed
charliermarsh wants to merge 1 commit intomainfrom
Closed
Remove shadowed import, rather than shadowing import, in F811#10388charliermarsh wants to merge 1 commit intomainfrom
charliermarsh wants to merge 1 commit intomainfrom
Conversation
Member
Author
|
I think this isn't a great idea. |
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Today, in F811, if you have code like:
We flag a violation on the second line (the line of the redefinition), and the fix we generate is a removal of the second import. In #10387, I removed the fix in these cases, when the imports map to different symbols.
It seems "more correct", though to remove the first import, since the second import is the one that will actually be used in practice. This PR changes that behavior.
However, I'm sure if this is actually correct, because we're now changing code that's far away from the violation itself. There's an example in our test suite that shows why this isn't ideal:
In this case, we'd remove the
Sequence # noqaline, since the# noqaisn't on the line containing the F811 violation. (I'm not really interested in parsing out the# noqaviolation from theSequence # noqaline, because it risks breaking a bunch of assumptions about how# noqaworks.)Anyway, interested in feedback.