Remove shadowed import, rather than shadowing import, in F811 #10388
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 # noqa
line, since the# noqa
isn't on the line containing the F811 violation. (I'm not really interested in parsing out the# noqa
violation from theSequence # noqa
line, because it risks breaking a bunch of assumptions about how# noqa
works.)Anyway, interested in feedback.