-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Remove unused imports in standard library #79383
Comments
Please find the modules where we need to remove. codecs.py:1105:5: F401 'encodings' imported but unused I was just wondering that as a community, do we recommend this practice of cleaning up Or just we keep as is inorder to NOT to break accidental imports? |
I have raised a partial PR here - #10438; if it is merged please take up the rest of the changes mentioned in the issue description. |
I think we can remove these in 3.8. My understanding of the policy (which I cannot find: the search terms are too generic) is that if a module defines __all__, and the symbol we want to remove isn't in it, then we can remove the symbol in the next feature release without requiring a deprecation period. If a module doesn't define __all__, then we need a deprecation period in order to remove a symbol, unless the symbol is a module, and then we can just remove it in the next feature release. |
Let me restate that: I think we can remove these in 3.8 if they're not in the module's __all__. I haven't checked that, although it would surprise me if any of them were in __all__. |
There's a few that should be discussed with the module maintainers first. A patch for IDLE should go through Terry Reedy. The "java.lang" in platform isn't a normal import and may have something to do with Jython. The "abc" in typing.py might be there for a reason, so ask Guido before zapping it. It's also possible that "encodings" might be in codecs for a reason as well, but I'm not sure who you should check with. I'm not sure about readline, rlcompleter, sitecustomize, and usercustomize. I think think those imports may be there for their side-effects. Just importing them may suffice to enable some behavior, so be careful with these. |
Srinivas, if you thing the issue is finished, please close it. Otherwise say something about what is left to do. |
I have raised one more PR; I think i am done with this issue. People who are interested can take up from here. , For the record, following are some filters to search; Query to find unused imports find . -type f -name \*.py -print | xargs flake8 | grep F401 Search query |
With the current PR, i think i removed all unused imports in Lib folder. |
Thank you for the cleanup. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: