-
Notifications
You must be signed in to change notification settings - Fork 6
(Python) Validate code components extraction #20
Copy link
Copy link
Open
Labels
Description
For python documents, we can validate (or replace) GPT's code components extraction by using the ast library: Ex.
def extract_classes_and_functions(source_code):
parsed_tree = ast.parse(source_code)
classes = []
functions = []
for node in ast.walk(parsed_tree):
if isinstance(node, ast.ClassDef):
classes.append(node)
elif isinstance(node, ast.FunctionDef):
functions.append(node)
return classes, functions
Reactions are currently unavailable