Skip to content

Commit

Permalink
Update to work with Poetry 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
j-adamczyk committed Jan 26, 2025
1 parent bf88c71 commit b1fdd52
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pre_commit_hooks/safety_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ def main(argv=None): # pylint: disable=inconsistent-return-statements
pyproject_toml_filepath = files[0]
with pyproject_toml_filepath.open() as pyproject_file:
lines = [line.strip() for line in pyproject_file.readlines()]
if any(line.startswith("[tool.poetry]") for line in lines):

poetry_project = any(
(
line.startswith("[tool.poetry")
or "poetry-core" in line or
"poetry.core.masonry.api" in line
)
for line in lines
)
if poetry_project:
with convert_poetry_to_requirements(pyproject_toml_filepath, groups=parsed_args.groups) as tmp_requirements:
return call_safety_check([tmp_requirements.name], parsed_args.ignore, parsed_args.report_arg, args_rest)
parser.error("Unsupported build tool: this pre-commit hook currently only handles pyproject.toml with Poetry"
Expand Down

0 comments on commit b1fdd52

Please sign in to comment.