LocalStack pre-commit hooks
You need to add pre-commit to your python environment and install the hooks:
pip install pre-commit
pre-commit install
Then, to use hooks from this repo add this to your .pre-commit-config.yaml
:
repos:
- repo: https://github.com/localstack/pre-commit-hooks
rev: v1.2.1
hooks:
- id: check-pinned-deps-for-needed-upgrade
To run a hook manually on the staged changes use the following command:
pre-commit run <hook-id> --files $(git diff --name-only --cached)
check-pinned-deps-for-needed-upgrade
: This hook will notify contributors if the project file has changed and the pinned dependencies do not satisfy the project file. The project file can either bepyproject.toml
orsetup.cfg
. If thepyproject.toml
file contains aproject
section, the hook will check thepyproject.toml
file, otherwise it will check thesetup.cfg
file.
To add a new hook, create a new python file in the localstack_pre_commit
directory.
It should have a function called main
that takes a list of files as an argument.
The function should return a 0
if the hook passes and a 1
if it fails.
After creating the hook, add the main function to the project.scripts
section of the pyproject.toml
file using a concise script name.
Then create a new entry in the pre-commit-hooks.yaml
file giving the hook a unique id and referencing the script name from the pyproject.toml
file.
Also give a brief description of what the hook does.
Finally, add the hook to the README.md
file in the ## Available Hooks
section.