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

IDLE: Include nested functions and classes in module browser #44322

Closed
taleinat opened this issue Dec 9, 2006 · 16 comments
Closed

IDLE: Include nested functions and classes in module browser #44322

taleinat opened this issue Dec 9, 2006 · 16 comments
Assignees
Labels
3.7 (EOL) end of life topic-IDLE type-feature A feature request or enhancement

Comments

@taleinat
Copy link
Contributor

taleinat commented Dec 9, 2006

BPO 1612262
Nosy @terryjreedy, @ncoghlan, @devdanzin, @serwy, @csabella
PRs
  • bpo-1612262: IDLE: Class Browser shows nested functions and classes #2573
  • [3.6] bpo-1612262: IDLE: Class Browser shows nested functions, classes (GH-2573)  #3702
  • Dependencies
  • bpo-6691: Support for nested classes and function for pyclbr
  • bpo-30881: IDLE: add docstrings to browser.py
  • Files
  • classbrowser_nesting_support.diff
  • 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 2017-09-22.21:34:32.114>
    created_at = <Date 2006-12-09.17:38:55.000>
    labels = ['expert-IDLE', 'type-feature', '3.7']
    title = 'IDLE: Include nested functions and classes in module browser'
    updated_at = <Date 2017-09-23.20:45:10.472>
    user = 'https://github.com/taleinat'

    bugs.python.org fields:

    activity = <Date 2017-09-23.20:45:10.472>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2017-09-22.21:34:32.114>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2006-12-09.17:38:55.000>
    creator = 'taleinat'
    dependencies = ['6691', '30881']
    files = ['14706']
    hgrepos = []
    issue_num = 1612262
    keywords = ['patch']
    message_count = 16.0
    messages = ['30777', '84594', '89549', '91499', '91509', '250596', '297297', '297974', '299794', '301929', '301930', '301947', '302716', '302767', '302776', '302777']
    nosy_count = 6.0
    nosy_names = ['terry.reedy', 'ncoghlan', 'ajaksu2', 'gpolo', 'roger.serwy', 'cheryl.sabella']
    pr_nums = ['2573', '3702']
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1612262'
    versions = ['Python 3.6', 'Python 3.7']

    @taleinat
    Copy link
    Contributor Author

    taleinat commented Dec 9, 2006

    If I define a class within a class, like this:

    class A:
        class B:
            pass
        
        def foo(self):
            pass

    The class browser shows that A contains foo, but it doesn't show B at all.

    @devdanzin
    Copy link
    Mannequin

    devdanzin mannequin commented Mar 30, 2009

    Confirmed on trunk and py3k.

    @devdanzin devdanzin mannequin added type-feature A feature request or enhancement labels Mar 30, 2009
    @serwy
    Copy link
    Mannequin

    serwy mannequin commented Jun 20, 2009

    The class browser relies on the pyclbr module to scan the code. This
    module doesn't support classes within classes. Both pyclbr and IDLE's
    class browser need to be modified.

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Aug 12, 2009

    The attached patch adds support for nested objects in pyclbr and also in
    ClassBrowser.

    I have yet to find an optimal way to test this on test_pyclbr (I did
    some things here, none very nice), so you will notice tests are missing
    on this patch.

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Aug 12, 2009

    I've removed the previous patch from here and attached an updated one on
    bpo-6691.

    Now the patch attached here only contains changes related to
    idlelib.ClassBrowser.

    @terryjreedy
    Copy link
    Member

    Class Browser is now a module browser as it includes functions not in classes. I guess pyclbr does this. Enhancing this for current versions would require adding a private copy of enhanced pyclbr to idlelib.

    @terryjreedy
    Copy link
    Member

    I believe the patch for bpo-6691 will also add detection of nested functions. If so, the IDLE patch must also make use of that new information.

    If the patch for bpo-6691 is only applied to 3.7, I want to put a temporary copy of the revised pyclbr in 3.6 idlelib, perhaps as _pyclbr, and change the 3.6 import accordingly.

    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label Jun 29, 2017
    @terryjreedy terryjreedy self-assigned this Jun 29, 2017
    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label Jun 29, 2017
    @terryjreedy terryjreedy self-assigned this Jun 29, 2017
    @csabella
    Copy link
    Contributor

    csabella commented Jul 9, 2017

    I created bpo-30881 to add docstrings to browser.py to make creating user tests easier.

    @csabella
    Copy link
    Contributor

    csabella commented Aug 5, 2017

    I added a more complete set of unit tests to the PR.

    @terryjreedy
    Copy link
    Member

    Nick, this over-due improvement to IDLE depends on the over-due improvement to pyclbr in 3.7. I would like to backport the IDLE improvement by putting a copy of 3.7 pyclbr in 3.6 idlelib. Do you agree that PEP-434 allows this?

    @terryjreedy
    Copy link
    Member

    Would it make any difference if the module were renamed? and made to only work with IDLE?

    @ncoghlan
    Copy link
    Contributor

    I think a bundled copy as idlelib._pyclbr in the 3.6 branch would be within the intent of PEP-434.

    @terryjreedy
    Copy link
    Member

    I am revising the codecontext patch to use comprehensions and the sort key option. I will rename the new function 'collect_objects' (GPolo) / '_traverse_node' (CSabella) as 'list_children' and have it return the name-object list, ordered by line number, needed by the tree widget.

    [The input is a dictionary of children of a node, rather than a node, because pyclbr returns the dictionary of the children of the root module node of the tree, rather than a root node itself. Sorting is not actually needed for 3.6/7 because the dicts are already ordered, but pyclbr does not guarantee this by using OrderedDict. Proposing these two changes is a separate potential issue.]

    @terryjreedy
    Copy link
    Member

    New changeset 058de11 by Terry Jan Reedy (Cheryl Sabella) in branch 'master':
    bpo-1612262: IDLE: Class Browser shows nested functions, classes (bpo-2573)
    058de11

    @terryjreedy
    Copy link
    Member

    New changeset fa1cae5 by Terry Jan Reedy in branch '3.6':
    [3.6] bpo-1612262: IDLE: Class Browser shows nested functions, classes (GH-2573) (bpo-3702)
    fa1cae5

    @terryjreedy
    Copy link
    Member

    I settled on 'transform_children' for the new function. bpo-31461 is the master issue for improving the browsers.

    @terryjreedy terryjreedy changed the title Class Browser doesn't show internal classes IDLE: Include nested functions and classes in module browser Sep 23, 2017
    @terryjreedy terryjreedy changed the title Class Browser doesn't show internal classes IDLE: Include nested functions and classes in module browser Sep 23, 2017
    @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.7 (EOL) end of life topic-IDLE type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants