Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Feb 3, 2020
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 12, 2020

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).

Would have caught #16189 (comment).

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@@ -7,12 +7,12 @@
import numpy as np
from numpy import ma

import matplotlib.category as _ # <-registers a category unit converter
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@timhoffm timhoffm Feb 3, 2020

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. 😄

Copy link
Contributor Author

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.

@tacaswell tacaswell added this to the v3.3.0 milestone Jan 13, 2020
`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).
@Kojoley Kojoley merged commit f2b3051 into matplotlib:master Feb 3, 2020
@anntzer anntzer deleted the shadowed branch February 3, 2020 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants