Pre-commit¶
The hooks will run when doing normal git commit
and git push
commands. It's recommended to do this in the command line to see the output. If performing these actions from a gui application, the interface may seem to hang for some time.
The pre-commit checks should be fast while the pre-push hooks will take longer since they'll do a full rebuild
Installation¶
It's recommended to install "global" tools via pipx, which installs packages in an isolated environment rather than the global python environment.
-
Install pre-commit
-
Add the hook to git
Pre-commit is now set up to check your files whenever you commit or push code.
-
Test by adding an empty commit
You should see a list of tests that are all skipped, because there's no changes in the commit to test.
Extra information¶
-
To skip the checks temporarily, you can do one of these
-
Manually run the hooks (this runs it against all files rather than only changed files)
-
More commands to run the hooks
-
Update pre-commit and plugins to the latest version