From 88c8f2466e65af0bdb1fae7931201d378368ca3b Mon Sep 17 00:00:00 2001 From: dalthviz Date: Thu, 9 Apr 2020 22:18:59 -0500 Subject: [PATCH 1/2] Object Explorer: Remove restriction to populate obj attributes --- .../widgets/objectexplorer/tree_model.py | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py index f57ce9fed2d..a3558c06137 100644 --- a/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py +++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py @@ -284,29 +284,27 @@ def _fetchObjectChildren(self, obj, obj_path): path_strings = [] tree_items = [] - # Only populate children for objects without their own editor - if not is_editable_type(obj): - is_attr_list = [False] * len(obj_children) - - # Object attributes - # Needed to handle errors while getting object's attributes - # Related with spyder-ide/spyder#6728 and spyder-ide/spyder#9959 - for attr_name in dir(obj): - try: - attr_value = getattr(obj, attr_name) - obj_children.append((attr_name, attr_value)) - path_strings.append('{}.{}'.format(obj_path, attr_name) - if obj_path else attr_name) - is_attr_list.append(True) - except Exception: - # Attribute could not be get - pass - assert len(obj_children) == len(path_strings), "sanity check" - - for item, path_str, is_attr in zip(obj_children, path_strings, - is_attr_list): - name, child_obj = item - tree_items.append(TreeItem(child_obj, name, path_str, is_attr)) + is_attr_list = [False] * len(obj_children) + + # Object attributes + # Needed to handle errors while getting object's attributes + # Related with spyder-ide/spyder#6728 and spyder-ide/spyder#9959 + for attr_name in dir(obj): + try: + attr_value = getattr(obj, attr_name) + obj_children.append((attr_name, attr_value)) + path_strings.append('{}.{}'.format(obj_path, attr_name) + if obj_path else attr_name) + is_attr_list.append(True) + except Exception: + # Attribute could not be get + pass + assert len(obj_children) == len(path_strings), "sanity check" + + for item, path_str, is_attr in zip(obj_children, path_strings, + is_attr_list): + name, child_obj = item + tree_items.append(TreeItem(child_obj, name, path_str, is_attr)) return tree_items From 5e3e8e6e6e596066aba558321056cb5fa296bb1f Mon Sep 17 00:00:00 2001 From: dalthviz Date: Fri, 10 Apr 2020 10:25:38 -0500 Subject: [PATCH 2/2] Object Explorer: Update root children row count --- .../widgets/objectexplorer/tests/test_objectexplorer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py index 0e7dac9d98d..24ae64a12be 100644 --- a/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py +++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py @@ -129,8 +129,8 @@ def test_objectexplorer_collection_types(objectexplorer, params): model = editor.obj_tree.model() # The row for the variable assert model.rowCount() == 1 - # Root row without children - assert model.rowCount(model.index(0, 0)) == 0 + # Root row without children: 71 in Python 2, 78 in Python 3 + assert model.rowCount(model.index(0, 0)) in [71, 78] assert model.columnCount() == 11