This repository was archived by the owner on Nov 3, 2023. It is now read-only.
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
The pre-commit hook fails silently when a pyproject.toml file exists and toml isn't installed #603
Open
Description
#534 enabled usage of pydocstyle
with pyproject.toml
for configuration. In that PR, it was discussed that toml
shouldn't be a hard dependency for using pydocstyle
(which I agree with), and that it should simply throw a warning if a pyproject.toml
file is detected without the toml
package present to read it. However, this is problematic when using pydocstyle
as a pre-commit
hook because pre-commit
will silently consume stdout
unless the hook returns a nonzero exit code.
I see a few potential solutions here, which I've placed in order of preference:
- Use the
additional_dependencies
feature ofpre-commit
to always requiretoml
when installing thepydocstyle
pre-commit
hook. I see the argument for not wanting to error withouttoml
in a general setting, but in the context ofpre-commit
where the dependencies can be tightly managed I think it's OK to have this dependency encoded. - Change the warning to an error, but also add a grep (or equivalent) of a
pyproject.toml
file (if one exists) to see whether the string[tool.pydocstyle]
is present in the file as a precondition of erroring. This is a bit more engineering effort, but if avoiding requiringtoml
is important enough even in apre-commit
hook then this would be a way to do a more cursory check of the file without parsing it. - Set
verbose: True
in thepre-commit
hook definition. This choice has the downside of always makingpydocstyle
noisier, but it at least ensures that the warning will be visible. - The status quo. This solution puts the onus on the user to realize that
pydocstyle
fails silently in this case. I personally don't think this is a viable solution, but I listed it in case the project maintainers feel otherwise.
I am happy to make a PR if we could come to a consensus on the preferred solution.
Metadata
Metadata
Assignees
Labels
No labels