Skip to content
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

Closed
srinivasreddy mannequin opened this issue Nov 9, 2018 · 14 comments
Closed

Remove unused imports in standard library #79383

srinivasreddy mannequin opened this issue Nov 9, 2018 · 14 comments
Labels
3.8 only security fixes

Comments

@srinivasreddy
Copy link
Mannequin

srinivasreddy mannequin commented Nov 9, 2018

BPO 35202
Nosy @rhettinger, @terryjreedy, @ericvsmith, @srinivasreddy, @miss-islington
PRs
  • bpo-35202: Remove unused imports in idle lib package #10438
  • bpo-35202: Remove unused imports in Lib directory  #10445
  • bpo-35202: Remove unused imports in Lib directory #10446
  • [3.7] bpo-35202: Remove unused imports in idlelib (GH-10438) #10447
  • [3.6] bpo-35202: Remove unused imports in idlelib (GH-10438) #10448
  • bpo-35202: Remove unused imports in Lib directory #10450
  • bpo-35202: Remove unused imports #10561
  • bpo-35202: Remove more unused imports in idlelib #10573
  • [3.7] bpo-35202: Remove more unused imports in idlelib (GH-10573) #10582
  • [3.6] bpo-35202: Remove more unused imports in idlelib (GH-10573) #10583
  • 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:

    assignee = None
    closed_at = <Date 2018-11-17.07:03:32.101>
    created_at = <Date 2018-11-09.19:09:11.979>
    labels = ['3.8']
    title = 'Remove unused imports in standard library'
    updated_at = <Date 2018-11-17.07:03:32.100>
    user = 'https://github.com/srinivasreddy'

    bugs.python.org fields:

    activity = <Date 2018-11-17.07:03:32.100>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-11-17.07:03:32.101>
    closer = 'terry.reedy'
    components = []
    creation = <Date 2018-11-09.19:09:11.979>
    creator = 'thatiparthy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35202
    keywords = ['patch']
    message_count = 14.0
    messages = ['329548', '329553', '329563', '329564', '329567', '329597', '329598', '329599', '329603', '329604', '329984', '330024', '330025', '330026']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'terry.reedy', 'eric.smith', 'thatiparthy', 'miss-islington']
    pr_nums = ['10438', '10445', '10446', '10447', '10448', '10450', '10561', '10573', '10582', '10583']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue35202'
    versions = ['Python 3.8']

    @srinivasreddy
    Copy link
    Mannequin Author

    srinivasreddy mannequin commented Nov 9, 2018

    Please find the modules where we need to remove.

    codecs.py:1105:5: F401 'encodings' imported but unused
    code.py:298:13: F401 'readline' imported but unused
    platform.py:118:1: F401 'warnings' imported but unused
    platform.py:509:9: F401 'java.lang' imported but unused
    pstats.py:562:9: F401 'readline' imported but unused
    shutil.py:13:1: F401 'io' imported but unused
    site.py:409:13: F401 'rlcompleter' imported but unused
    site.py:511:13: F401 'sitecustomize' imported but unused
    site.py:531:13: F401 'usercustomize' imported but unused
    trace.py:54:1: F401 're' imported but unused
    typing.py:21:1: F401 'abc' 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?

    @srinivasreddy
    Copy link
    Mannequin Author

    srinivasreddy mannequin commented Nov 9, 2018

    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.

    @ericvsmith
    Copy link
    Member

    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.

    @ericvsmith ericvsmith added the 3.8 only security fixes label Nov 9, 2018
    @ericvsmith
    Copy link
    Member

    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__.

    @rhettinger
    Copy link
    Contributor

    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.

    @terryjreedy
    Copy link
    Member

    New changeset 43a74ab by Terry Jan Reedy (Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి)) in branch 'master':
    bpo-35202: Remove unused imports in idlelib (GH-10438)
    43a74ab

    @miss-islington
    Copy link
    Contributor

    New changeset 2847cca by Miss Islington (bot) in branch '3.7':
    bpo-35202: Remove unused imports in idlelib (GH-10438)
    2847cca

    @miss-islington
    Copy link
    Contributor

    New changeset 2903b0f by Miss Islington (bot) in branch '3.6':
    bpo-35202: Remove unused imports in idlelib (GH-10438)
    2903b0f

    @terryjreedy
    Copy link
    Member

    Srinivas, if you thing the issue is finished, please close it. Otherwise say something about what is left to do.

    @srinivasreddy
    Copy link
    Mannequin Author

    srinivasreddy mannequin commented Nov 10, 2018

    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
    ------------------------------------
    grep -v warnings | grep -v "\.\*" | grep -v tkinter | grep -v sysconfig | grep -v readline | grep -v py3_test_grammar.py | grep -v java | grep -v rlcompleter | grep -v sitecustomize | grep -v __all__ | grep -v test_importlib | grep -v async | grep -v test_future | grep -v circular_import | grep -v dataclasses
    ------------------------------------

    @srinivasreddy
    Copy link
    Mannequin Author

    srinivasreddy mannequin commented Nov 16, 2018

    With the current PR, i think i removed all unused imports in Lib folder.

    @miss-islington
    Copy link
    Contributor

    New changeset 3a600d2 by Miss Islington (bot) in branch '3.7':
    bpo-35202: Remove more unused imports in idlelib (GH-10573)
    3a600d2

    @miss-islington
    Copy link
    Contributor

    New changeset 8d816f7 by Miss Islington (bot) in branch '3.6':
    bpo-35202: Remove more unused imports in idlelib (GH-10573)
    8d816f7

    @terryjreedy
    Copy link
    Member

    Thank you for the cleanup.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants