-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Comments
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. |
Confirmed on trunk and py3k. |
The class browser relies on the pyclbr module to scan the code. This |
The attached patch adds support for nested objects in pyclbr and also in I have yet to find an optimal way to test this on test_pyclbr (I did |
I've removed the previous patch from here and attached an updated one on Now the patch attached here only contains changes related to |
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. |
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. |
I created bpo-30881 to add docstrings to browser.py to make creating user tests easier. |
I added a more complete set of unit tests to the PR. |
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? |
Would it make any difference if the module were renamed? and made to only work with IDLE? |
I think a bundled copy as idlelib._pyclbr in the 3.6 branch would be within the intent of PEP-434. |
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.] |
New changeset 058de11 by Terry Jan Reedy (Cheryl Sabella) in branch 'master': |
New changeset fa1cae5 by Terry Jan Reedy in branch '3.6': |
I settled on 'transform_children' for the new function. bpo-31461 is the master issue for improving the browsers. |
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: