-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Catch shadowed imports in style checks. #16193
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
Conversation
@@ -7,12 +7,12 @@ | |||
import numpy as np | |||
from numpy import ma | |||
|
|||
import matplotlib.category as _ # <-registers a category unit converter |
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.
Actually, I like the idea of import as _
to mark an unused import, but won't insistent on it.
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.
It is a nice way to mark that something a bit funny (side effects on import) is going on here.
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 rewrote the comment to more forcefully point to the side-effect, but I can also just revert the change and flake8-exclude this file if you prefer.
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.
My preferred version would be,
import matplotlib.category as _ # Register category unit converter
or keep your version but without the exclamation marks. I'm quite allergic to them, even more so, if there's more than one. 😄
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.
Ah, I guess I forgot to mention that this is needed because the underscore-import triggers F811 per PyCQA/pyflakes#366.
I just removed the exclamation marks for now.
`matplotlib.rc_context` is redefined in pyplot with a wrapper function so that it shows up in the docs (like setp, getp and a few others). spines imports cbook twice. The imports of category and dates in _axes.py don't need to be assigned to "_" (they're not assigned to a global name to start with anyways).
matplotlib.rc_context
is redefined in pyplot with a wrapper functionso that it shows up in the docs (like setp, getp and a few others).
spines imports cbook twice.
The imports of category and dates in
_axes.py
don't need to be assignedto "_" (they're not assigned to a global name to start with anyways).
Would have caught #16189 (comment).
PR Summary
PR Checklist