From b5b25286909cf8557ff9a1ba2a25b1bbc67b783a Mon Sep 17 00:00:00 2001 From: Aaron Munger Date: Tue, 16 Apr 2024 19:29:50 -0700 Subject: [PATCH] filter out unneeded variables, bring back privates but sort them to the end (#15551) --- .../vscodeGetVariablesForProvider.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pythonFiles/vscode_datascience_helpers/getVariableInfo/vscodeGetVariablesForProvider.py b/pythonFiles/vscode_datascience_helpers/getVariableInfo/vscodeGetVariablesForProvider.py index 7cefe516b98..f83fe015638 100644 --- a/pythonFiles/vscode_datascience_helpers/getVariableInfo/vscodeGetVariablesForProvider.py +++ b/pythonFiles/vscode_datascience_helpers/getVariableInfo/vscodeGetVariablesForProvider.py @@ -58,10 +58,13 @@ def getValue(variable): def getPropertyNames(variable): props = [] + privateProps = [] for prop in dir(variable): if not prop.startswith("_"): props.append(prop) - return props + elif not prop.startswith("__"): + privateProps.append(prop) + return props + privateProps def getFullType(varType): @@ -74,6 +77,9 @@ def getFullType(varType): return module + varType.__name__ +typesToExclude = ["module", "function", "method", "class", "type"] + + def getVariableDescription(variable): result = {} @@ -126,6 +132,7 @@ def _VSCODE_getVariableDescriptions(varNames): } for varName in varNames if varName in globals() + and type(globals()[varName]).__name__ not in typesToExclude ] return json.dumps(variables) @@ -167,7 +174,10 @@ def _VSCODE_getAllChildrenDescriptions(rootVarName, propertyChain, startIndex): children = [] for prop in childrenNames: child_property = getChildProperty(parent, [prop]) - if child_property is not None and type(child_property).__name__ != "method": + if ( + child_property is not None + and type(child_property).__name__ not in typesToExclude + ): child = { **getVariableDescription(child_property), "name": prop,