Skip to content

Commit

Permalink
filter out unneeded variables, bring back privates but sort them to t…
Browse files Browse the repository at this point in the history
…he end (#15551)
  • Loading branch information
amunger authored Apr 17, 2024
1 parent 5a80a72 commit b5b2528
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -74,6 +77,9 @@ def getFullType(varType):
return module + varType.__name__


typesToExclude = ["module", "function", "method", "class", "type"]


def getVariableDescription(variable):
result = {}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b5b2528

Please sign in to comment.