From 2737448747cf03da803dd4966084761f83c5000a Mon Sep 17 00:00:00 2001 From: Abraham Long Date: Thu, 16 Sep 2021 07:20:27 -0400 Subject: [PATCH] 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. --- pipreqs/pipreqs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index 24eeeb7..3ac1fc1 100644 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -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: