Skip to content

Commit 27bf428

Browse files
ayman-salehAyman Salehglenn-jocher
authored
Fix check_requirements() resource warning allocation open file (#5602)
* 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]>
1 parent 7ebb5e5 commit 27bf428

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

utils/general.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), insta
264264
if isinstance(requirements, (str, Path)): # requirements.txt file
265265
file = Path(requirements)
266266
assert file.exists(), f"{prefix} {file.resolve()} not found, check failed."
267-
requirements = [f'{x.name}{x.specifier}' for x in pkg.parse_requirements(file.open()) if x.name not in exclude]
267+
with file.open() as f:
268+
requirements = [f'{x.name}{x.specifier}' for x in pkg.parse_requirements(f) if x.name not in exclude]
268269
else: # list or tuple of packages
269270
requirements = [x for x in requirements if x not in exclude]
270271

0 commit comments

Comments
 (0)