How to set the path for repository local pre-commit hooks

82 Views Asked by At

Pre-commit allows repository local hooks which are useful for project-specific lints.

For hooks with the language script you can specify its path just using entry, e.g:

-   repo: local
    hooks:
    -   id: check-x
        name: Check X
        entry: ./bin/check-x.sh
        language: script

However when you use the language python, the entry is just the name of the entry point of the Python package to use. How can I tell it where the Python package is located within my repo?

1

There are 1 best solutions below

4
anthony sottile On

despite your assertion, entry is not the python package -- but the executable to be used. it is common that this matches the python package provided, but is not a requirement or a guarantee for python packaging (pre-commit/pre-commit-hooks has many examples where they do not match)

pre-commit never installs the repository under test so you'll not have access to any executables that may be provided by packages there.

for repo: local, language: python can refer to either executables provided by things in additional_dependencies or it can be paths to scripts within your repository (the same as language: script)


disclaimer: I wrote pre-commit