dedent before ast.parse for non-toplevel functions
This commit is contained in:
@ -8,6 +8,7 @@ import ast
|
||||
import io
|
||||
import tokenize
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
import numpy as np
|
||||
|
||||
@ -45,7 +46,7 @@ def strip_comments(source: str) -> str:
|
||||
for child in ast.iter_child_nodes(node):
|
||||
remove_docstrings(child)
|
||||
|
||||
tree = ast.parse(source)
|
||||
tree = ast.parse(textwrap.dedent(source))
|
||||
remove_docstrings(tree)
|
||||
code_without_docstrings = ast.unparse(tree)
|
||||
|
||||
|
Reference in New Issue
Block a user