Commit
•
27bf428
1
Parent(s):
7ebb5e5
Fix `check_requirements()` resource warning allocation open file (#5602)
Browse files* 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]>
- utils/general.py +2 -1
utils/general.py
CHANGED
@@ -264,7 +264,8 @@ def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), insta
|
|
264 |
if isinstance(requirements, (str, Path)): # requirements.txt file
|
265 |
file = Path(requirements)
|
266 |
assert file.exists(), f"{prefix} {file.resolve()} not found, check failed."
|
267 |
-
|
|
|
268 |
else: # list or tuple of packages
|
269 |
requirements = [x for x in requirements if x not in exclude]
|
270 |
|
|
|
264 |
if isinstance(requirements, (str, Path)): # requirements.txt file
|
265 |
file = Path(requirements)
|
266 |
assert file.exists(), f"{prefix} {file.resolve()} not found, check failed."
|
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]
|
269 |
else: # list or tuple of packages
|
270 |
requirements = [x for x in requirements if x not in exclude]
|
271 |
|