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 <aymansaleh@Aymans-MacBook-Pro-2.local> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>pull/5608/head
parent
7ebb5e5da6
commit
27bf4282d3
|
@ -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]
|
||||
|
||||
|
|
Loading…
Reference in New Issue