Fix several ResourceWarning: unclosed file

This commit is contained in:
Mickaël Schoentgen 2018-08-10 10:21:20 +02:00
parent abee146199
commit 67d6fcb0f6
10 changed files with 78 additions and 34 deletions

View file

@ -38,7 +38,8 @@ def _hook_paths(git_root, hook_type):
def is_our_script(filename):
if not os.path.exists(filename):
return False
contents = io.open(filename).read()
with io.open(filename) as f:
contents = f.read()
return any(h in contents for h in (CURRENT_HASH,) + PRIOR_HASHES)