Skip to content

Commit

Permalink
Fix check_requirements() resource warning allocation open file (#5602)
Browse files Browse the repository at this point in the history
* Fix to resource warning allocation; utilize file.open within a context manager

* rename fh to f

in keeping with naming convention

Co-authored-by: Ayman Saleh <[email protected]>
Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
3 people authored Nov 10, 2021
1 parent 7ebb5e5 commit 27bf428
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), insta
if isinstance(requirements, (str, Path)): # requirements.txt file
file = Path(requirements)
assert file.exists(), f"{prefix} {file.resolve()} not found, check failed."
requirements = [f'{x.name}{x.specifier}' for x in pkg.parse_requirements(file.open()) if x.name not in exclude]
with file.open() as f:
requirements = [f'{x.name}{x.specifier}' for x in pkg.parse_requirements(f) if x.name not in exclude]
else: # list or tuple of packages
requirements = [x for x in requirements if x not in exclude]

Expand Down

0 comments on commit 27bf428

Please sign in to comment.