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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ignore =
E265, E266,
E305, E306,
E722, E741,
F811, F841,
F841,
# Some new flake8 ignores:
N801, N802, N803, N806, N812,
# pydocstyle
Expand Down Expand Up @@ -50,7 +50,7 @@ per-file-ignores =
lib/matplotlib/lines.py: F401
lib/matplotlib/mathtext.py: E221, E251
lib/matplotlib/pylab.py: F401, F403
lib/matplotlib/pyplot.py: F401
lib/matplotlib/pyplot.py: F401, F811
lib/matplotlib/rcsetup.py: E501
lib/matplotlib/style/__init__.py: F401
lib/matplotlib/testing/conftest.py: F401
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

import matplotlib.category # Register category unit converter as side-effect.
import matplotlib.cbook as cbook
import matplotlib.collections as mcoll
import matplotlib.colors as mcolors
import matplotlib.contour as mcontour
import matplotlib.dates as _ # <-registers a date unit converter
import matplotlib.dates # Register date unit converter as side-effect.
import matplotlib.docstring as docstring
import matplotlib.image as mimage
import matplotlib.legend as mlegend
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from matplotlib.figure import Figure, figaspect
from matplotlib.gridspec import GridSpec
from matplotlib import rcParams, rcParamsDefault, get_backend, rcParamsOrig
from matplotlib import rc_context
from matplotlib.rcsetup import interactive_bk as _interactive_bk
from matplotlib.artist import Artist
from matplotlib.axes import Axes, Subplot
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/spines.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import matplotlib
from matplotlib import cbook, docstring, rcParams
from matplotlib.artist import allow_rasterization
import matplotlib.cbook as cbook
import matplotlib.transforms as mtransforms
import matplotlib.patches as mpatches
import matplotlib.path as mpath
Expand Down