-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Clean up unused imports #12562
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
Comments
I will remove them. |
Please check carefully, what you are removing. There are some unused imports that can actually be removed, however, there are others which are intentionally in place (e.g. for making code elements accessible to the user from another namespace). |
We need to be extremely careful about removing imports. Because the
codebase predates the days of `__all__` usage, we have found that people
have been mis-accessing submodules within matplotlib for years. We have had
a few past PRs that incidentally cleaned up some imports, only to later get
reports of breaking people's code.
…On Thu, Oct 18, 2018 at 5:11 PM tkivisik ***@***.***> wrote:
I will remove them.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#12562 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-Hq_ZGThnnlwLAA8VdELcMlflmWtks5umO6BgaJpZM4XvPFH>
.
|
Thank you for the warnings. In that case retract from claiming this for myself and I leave this up for someone with more intimate knowledge of the project. When some eager person would like to take this on, which approach would make you confident that no necessary imports are removed? |
I've removed some obviously unused imports. As a rule of thumb:
|
Thanks for explaining the guidelines and removing unused imports. |
To add to @timhoffm 's list,
|
you'd be surprised by how many people can be impacted by the removal of a
third-party import. I remember seeing a bunch of bug reports when I changed
how basemap was importing pyproj. I kinda wish that there was some sort of
way to force all new packages to adopt `__all__` usage. Even I forget to
set it sometimes in my own projects. It is one of those things that doesn't
pay off right away, but is a huge "I wish I did that 10 years ago" kind of
thing.
…On Sat, Oct 20, 2018 at 10:23 AM Thomas A Caswell ***@***.***> wrote:
To add to @timhoffm <https://github.com/timhoffm> 's list,
- removing standard library / third-party imports is usually ok,
removing internal imports usually is not.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12562 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-EQKvgjid0tdXZg24tzxiZNb5Aenks5umzHigaJpZM4XvPFH>
.
|
As a result, most people won't notice the effect of In particular For an explanation see e.g. http://xion.io/post/code/python-all-wild-imports.html |
Bug report
There are 41 unused imports according to:
https://lgtm.com/projects/g/matplotlib/matplotlib/alerts/?mode=list
They should be removed.
Matplotlib version - latest from the master branch.
The text was updated successfully, but these errors were encountered: