-
Notifications
You must be signed in to change notification settings - Fork 79
[git] Setting up pre commit hooks
Git allows pre-commit hooks to run to help catch errors before committing them. The pre-commit hooks configured for this repository are lightweight checks (so not building a standalone or running pytest) that can be run and caught before the GitHub CI finds them.
- Install
pre-commit
:> pip install pre-commit
- Install the hooks:
> pre-commit install
- If you decide you don't want the hooks anymore, just run
> pre-commit uninstall
NOTE: If you work on a branch that doesn't have .pre-commit-config.yaml
, you'll have to temporarily uninstall the pre-commit hook.
That's it! Now any commits you make will have the hooks run on them to check for easy to find errors. Note that these checks are only run on modified files.
The first time the hooks are run, pre-commit
will setup some virtual environments for them which might take a little bit. You can "preload" these virtual environments and check all files using pre-commit run --all-files
.