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

Consistently group and sort imports within idlelib modules. #72078

Closed
terryjreedy opened this issue Aug 30, 2016 · 8 comments
Closed

Consistently group and sort imports within idlelib modules. #72078

terryjreedy opened this issue Aug 30, 2016 · 8 comments
Assignees
Labels
topic-IDLE type-feature A feature request or enhancement

Comments

@terryjreedy
Copy link
Member

BPO 27891
Nosy @terryjreedy
Files
  • imports-27891.diff
  • import-27891-2.diff: revise 3 files, add README material
  • 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 = 'https://github.com/terryjreedy'
    closed_at = <Date 2016-08-31.04:52:07.571>
    created_at = <Date 2016-08-30.01:46:59.441>
    labels = ['expert-IDLE', 'type-feature']
    title = 'Consistently group and sort imports within idlelib modules.'
    updated_at = <Date 2016-08-31.23:37:44.889>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2016-08-31.23:37:44.889>
    actor = 'python-dev'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-08-31.04:52:07.571>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2016-08-30.01:46:59.441>
    creator = 'terry.reedy'
    dependencies = []
    files = ['44261', '44288']
    hgrepos = []
    issue_num = 27891
    keywords = ['patch']
    message_count = 8.0
    messages = ['273892', '273895', '273897', '273905', '273906', '273994', '274000', '274078']
    nosy_count = 2.0
    nosy_names = ['terry.reedy', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27891'
    versions = ['Python 3.6']

    @terryjreedy
    Copy link
    Member Author

    PEP-8 suggests separately grouping stdlib, dependency, and local package imports. Within idlelib, idlelib imports are treated as local package imports. Tkinter is sometimes treated as a dependency, which makes its imports easy to notice, and I want to do this consistently. It is conventional to sort imports within each group. This is sometimes true now, sometimes not (even before the 3.6 renaming).

    The possible danger of rearranging imports is that a line gets deleted and not pasted. Rietveld's side-by-side diff should make this easy to detect.

    This issue is about re-arranging the imports currently at the top of a file, and any module level imports that I notice elsewhere. Dealing with delayed imports within functions and classed will be another issue, which will depend on this one.

    @terryjreedy terryjreedy self-assigned this Aug 30, 2016
    @terryjreedy terryjreedy added topic-IDLE type-feature A feature request or enhancement labels Aug 30, 2016
    @terryjreedy
    Copy link
    Member Author

    This issue includes adding the idlelib import coding standard to idlelib.README.

    The delayed-import issue is bpo-27893.

    A second followup will be to stop importing tkinter modules 'as' their Py 2 names. Change "from tkinter import font as TkFont" to "from tkinter import font" and globally replace 'TkFont' with 'tkfont'. Do the same for messagebox and any other submodules as needed.

    @terryjreedy
    Copy link
    Member Author

    On 2002 Sept 14, the following was merged into editor.py (then EditorWindow.py) as part of the smart indenting code added to the bottom.

    import tokenize
    _tokenize
    del tokenize

    This now would usually be written "import tokenize as _tokenize". Stdlib modules without explicit __all__ often do this to omit stdlib modules from their public interface. Idlelib does not do this. Add to README import standards. I put replaced the above with 'import tokenize' as the top where is belongs and changed all '_tokenize' to 'tokenize'.

    @terryjreedy
    Copy link
    Member Author

    Part of previous message should be 'at the top where it belongs'.

    With attached patch, each file compiles and (incomplete) tests pass. Will examine each with side-by-side diff. There might be artifacts from another patch left.

    @terryjreedy
    Copy link
    Member Author

    Followup is bpo-27892

    @terryjreedy
    Copy link
    Member Author

    Patch 2 has minor revisions to hyperparser, mainmenu, pyshell, and adds material to README.txt.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 31, 2016

    New changeset 96ac4cd43a20 by Terry Jan Reedy in branch 'default':
    Issue bpo-27891: Consistently group and sort imports within idlelib modules.
    https://hg.python.org/cpython/rev/96ac4cd43a20

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 31, 2016

    New changeset 28ce37a2d888 by Terry Jan Reedy in branch 'default':
    Issue bpo-27891: Tweak new idlelib README entry.
    https://hg.python.org/cpython/rev/28ce37a2d888

    @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
    topic-IDLE type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant