Skip to content

Commit

Permalink
Merge pull request #1597 from akhilnarang/fix-pyproject-open
Browse files Browse the repository at this point in the history
fix: use `with` to read pyproject.toml
  • Loading branch information
akhilnarang authored Nov 25, 2024
2 parents af8ed34 + f3110e5 commit aae99fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bench/utils/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ def _generate_dev_deps_pattern(pyproject_path):
from tomllib import loads

requirements_pattern = ""
pyroject_config = loads(open(pyproject_path).read())
with open(pyproject_path) as f:
pyproject_config = loads(f.read())

with contextlib.suppress(KeyError):
for pkg, version in pyroject_config["tool"]["bench"]["dev-dependencies"].items():
for pkg, version in pyproject_config["tool"]["bench"]["dev-dependencies"].items():
op = "==" if "=" not in version else ""
requirements_pattern += f"{pkg}{op}{version} "
return requirements_pattern
Expand Down

0 comments on commit aae99fa

Please sign in to comment.