MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / parse_tree

Function parse_tree

pythonwhat/checks/has_funcs.py:176–185  ·  view source on GitHub ↗
(tree)

Source from the content-addressed store, hash-verified

174 )
175
176 def parse_tree(tree):
177 # get contents of module.body if only 1 element
178 crnt = (
179 tree.body[0]
180 if isinstance(tree, ast.Module) and len(tree.body) == 1
181 else tree
182 )
183
184 # remove Expr if it exists
185 return ast.dump(crnt.value if isinstance(crnt, ast.Expr) else crnt)
186
187 stu_rep = parse_tree(state.student_ast)
188 sol_rep = parse_tree(state.solution_ast if not code else ast.parse(code))

Callers 1

has_equal_astFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected