File read error was not catched.

This commit is contained in:
Jarkko Hautakorpi 2022-01-11 16:07:26 +02:00
parent a593d27e3d
commit ca1628cf2b

View File

@ -111,9 +111,9 @@ def get_all_imports(
candidates += [os.path.splitext(fn)[0] for fn in files]
for file_name in files:
file_name = os.path.join(root, file_name)
with open(file_name, "r", encoding=encoding) as f:
contents = f.read()
try:
with open(file_name, "r", encoding=encoding) as f:
contents = f.read()
tree = ast.parse(contents)
for node in ast.walk(tree):
if isinstance(node, ast.Import):