Now when ast.parse() encounters a file that cannot be parsed due to syntax errors it will report that filename in it's traceback.

Now when ast.parse() encounters a file that cannot be parsed due to syntax errors it will report that filename in it's traceback.
This commit is contained in:
Abraham Long 2021-09-16 07:20:27 -04:00
parent a659ecb9c3
commit 2737448747

View File

@ -114,7 +114,7 @@ def get_all_imports(
with open(file_name, "r", encoding=encoding) as f:
contents = f.read()
try:
tree = ast.parse(contents)
tree = ast.parse(contents, filename=file_name)
for node in ast.walk(tree):
if isinstance(node, ast.Import):
for subnode in node.names: