-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add __all__ to pyplot #12743
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
base: main
Are you sure you want to change the base?
Add __all__ to pyplot #12743
Conversation
Note: CI for 3.5 is currently failing due to non-deterministic dict order. This can be worked around or defered until mpl 3.1, which will be python 3.6+ only. Not going to spend time on this before the general idea is discussed. |
You can be certain that a lot of people do things like
having started |
Except for the This is about defining a reasonable subset of pylab that should ease most use-cases while limiting the number of imported functions. |
I've found out about this problem today. Very confusing the fact that one can access the whole from matplotlib.pyplot import *
...
matplotlib.pyplot.savefig('myimage.png') I really support this change! |
I took the liberty of rebasing this and think it is ready to review. |
I think this needs a behavior change note indicating that we restricted the namespace, but otherwise 👍 |
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 think this makes sense. Will also help with #22149.
Happy to see this moving. Please be aware that this may not yet be ready
I'm sorry I don't have the time to work on this. Anybody can take over the PR and (force) push. |
Lets move to draft, but definitely anyone should feel free to put back... |
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
e9d8ff2
to
e2c9eb9
Compare
Rebased, but #12743 (comment) still applies. |
PR Summary
This introduces the
__all__
variable to pyplot, whose only purpose is to limit what is imported on a wildcard importfrom matplotlib.pyplot import *
.While wildcard imports are not recommended in general - and I don't want to change this, there appears to be still a lot of
from pylab import *
oripython --pylab
usage around. I assume that's because it's so convenient for quick interactive use. While we probably cannot change people completely, it may be a good idea to have a more limited and thus less dangerous wildcard import to help push people away from pylab. In particular we should only import relevant plotting functions here (no numpy, no mlab, no colormap functions)Note: This is currently a proof of concept and requires additional work.
pylab
since pylab usesfrom matplotlib.pyplot import *
, which is an unintended side-effect.__all__
needs some cleanup. Possible some are missing, while others are not neccesary.But before working futher on the details, I would like to reach a general consensus on the idea.
PR Checklist