Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
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 ourterms of service andprivacy 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
timhoffm commentedNov 4, 2018
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. |
ImportanceOfBeingErnest commentedNov 4, 2018
You can be certain that a lot of people do things like having started |
timhoffm commentedNov 4, 2018
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. |
dpshelio commentedMay 24, 2019
I've found out about this problem today. Very confusing the fact that one can access the whole frommatplotlib.pyplotimport*...matplotlib.pyplot.savefig('myimage.png') I really support this change! |
tacaswell commentedDec 5, 2022
I took the liberty of rebasing this and think it is ready to review. |
tacaswell commentedJan 19, 2023
I think this needs a behavior change note indicating that we restricted the namespace, but otherwise 👍 |
oscargus left a comment
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.
timhoffm commentedJan 20, 2023
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. |
jklymak commentedJan 24, 2023
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 toe2c9eb9Comparetimhoffm commentedMay 31, 2023
Rebased, but#12743 (comment) still applies. |
Uh oh!
There was an error while loading.Please reload this page.
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 --pylabusage 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.
pylabsince 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