dedent before ast.parse for non-toplevel functions
This commit is contained in:
1 parent
6d8b86c1ef
commit
7585e598dc
1 file changed
+2
-1
@@ -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