Fix resource warnings

This commit is contained in:
Anthony Sottile
2018-06-18 00:00:38 -07:00
parent a193eab99e
commit 5dc306b35d
7 changed files with 14 additions and 7 deletions

View File

@ -36,7 +36,8 @@ class DebugStatementParser(ast.NodeVisitor):
def check_file(filename):
try:
ast_obj = ast.parse(open(filename, 'rb').read(), filename=filename)
with open(filename, 'rb') as f:
ast_obj = ast.parse(f.read(), filename=filename)
except SyntaxError:
print('{} - Could not parse ast'.format(filename))
print()