[TYP/MNT] Remove unused imports from stub files#25787
Merged
tacaswell merged 1 commit intomatplotlib:mainfrom May 16, 2023
Merged
[TYP/MNT] Remove unused imports from stub files#25787tacaswell merged 1 commit intomatplotlib:mainfrom
tacaswell merged 1 commit intomatplotlib:mainfrom
Conversation
Member
|
Should we run isort on these as well? |
Member
Author
|
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. |
QuLogic
reviewed
Apr 29, 2023
| from matplotlib import cbook, ft2font | ||
| from matplotlib._fontconfig_pattern import ( | ||
| generate_fontconfig_pattern, | ||
| parse_fontconfig_pattern, |
Member
There was a problem hiding this comment.
Weirdly, this one is public enough to appear in API change notes, but not public enough to be in API documentation.
Member
Author
There was a problem hiding this comment.
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
QuLogic
approved these changes
Apr 29, 2023
Member
Author
|
Gentle ping on this one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -aon 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
pyclnover our code.The following additional changes were made after auditing the results:
<...>_COLORSdictionaries are explicitly exported in the colors moduletextmodule.textpathmodule which is at least arguably public (at least by way of not having a prepended_)textand thetextpathmodule is undocumentedlegend_handlerin thelegendmodule (legend_handleris its own public module, should be imported directly)layout_manager(even the ones that are documented contain a warning that they are considered private)_mathtextimport foo as fooare removed as those are holdout from generating the stub files and are not intended to be exported.pyfiles were excluded, though perhaps some should be removedeval(in galleries)pyclncould 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
pytestpasses)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.rstornext_api_changes/README.rst