Skip to content
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
@vyasr

Description

@vyasr

#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:

  1. Use the additional_dependencies feature of pre-commit to always require toml when installing the pydocstyle pre-commit hook. I see the argument for not wanting to error without toml in a general setting, but in the context of pre-commit where the dependencies can be tightly managed I think it's OK to have this dependency encoded.
  2. 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 requiring toml is important enough even in a pre-commit hook then this would be a way to do a more cursory check of the file without parsing it.
  3. Set verbose: True in the pre-commit hook definition. This choice has the downside of always making pydocstyle noisier, but it at least ensures that the warning will be visible.
  4. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions