-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[TYP/MNT] Remove unused imports from stub files #25787
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
Conversation
Should we run isort on these as well? |
We could do so, though may wish to add config to e.g. group the Not opposed, but also don't really see it as a huge gain. |
from matplotlib import cbook, ft2font | ||
from matplotlib._fontconfig_pattern import ( | ||
generate_fontconfig_pattern, | ||
parse_fontconfig_pattern, |
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.
Weirdly, this one is public enough to appear in API change notes, but not public enough to be in API documentation.
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.
Yeah, I was debating on this one, current leaning is to leave it out of stubs until and unless someone complains, which I kind of doubt will happen.
mostly performed by running pycln, but then manually audited
Gentle ping on this one |
PR Summary
mostly performed by running pycln, but then manually audited
After it was brought up in #25728 (comment), I did a bit of a review, and consulted the python/typeshed repo for guidance on best practices for type stub files.
That repo has a precommit hook to run
pycln -a
on all files, which removes any imports that are implementation details that are not used in the public interface of the module.Since that is the prevailing best practice of the relative authority on the matter, I decided to run
pycln
over our code.The following additional changes were made after auditing the results:
<...>_COLORS
dictionaries are explicitly exported in the colors moduletext
module.textpath
module which is at least arguably public (at least by way of not having a prepended_
)text
and thetextpath
module is undocumentedlegend_handler
in thelegend
module (legend_handler
is its own public module, should be imported directly)layout_manager
(even the ones that are documented contain a warning that they are considered private)_mathtext
import foo as foo
are removed as those are holdout from generating the stub files and are not intended to be exported.py
files were excluded, though perhaps some should be removedeval
(in galleries)pycln
could be added as a pre-commit hook here if we were interested, but would need to be properly configured, and current personal leaning is that it is not a big enough boon to do so, though checking when the topic comes up like it did here may be warranted.PR Checklist
Linked Issue
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst