Unverified 提交 27bf4282 authored 作者: Ayman Saleh's avatar Ayman Saleh 提交者: GitHub

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: 's avatarAyman Saleh <aymansaleh@Aymans-MacBook-Pro-2.local> Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 7ebb5e5d
......@@ -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]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论