Pre-commit hooks#
.pre-commit-config.yaml runs, on the files a commit changes:
Hook |
Check |
CI counterpart |
|---|---|---|
|
Removes outputs from Jupyter notebooks, except the archived ones under |
None |
|
Spelling, configured by |
The Typos workflow |
|
Lint rules, applying automatic fixes, on |
The Lint workflow ( |
|
Formatting, on the same paths |
The Lint workflow |
Install the hooks once per clone, and run them over the whole repository to check it independently of a commit:
python -m pip install pre-commit
pre-commit install
pre-commit run --all-files
A hook that rewrites a file fails the commit; stage the rewritten file and commit again. A deliberate exception is made for one commit, or for one hook by its id:
git commit --no-verify
SKIP=codespell git commit
Bypassing a local hook does not bypass CI: the Lint and Typos workflows run
the same checks on every pull request. The hook versions are pinned in the
configuration and CI installs the latest releases of ruff and codespell, so a
difference between the two is resolved by updating the pinned rev.