Shared pre-commit hooks for Alma repositories. They work with both prek and pre-commit.
Add the hooks you need to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/alma/pre-commit-hooks
rev: v2.0.0 # pin a full version, see below
hooks:
- id: uv-lock-scriptAlways pin a full vX.Y.Z version, never a branch. pre-commit caches each rev forever, so a moving
reference would never be updated on your machine. To get a PR when a new version is released, enable
Renovate's pre-commit manager. See the
releases for what changed.
| Hook | Description |
|---|---|
uv-lock-script |
Keeps the lock files of PEP 723 scripts up to date |
Keeps the <script>.py.lock lock file of every Python script with PEP 723
inline metadata up to date, with uv lock --script:
- a stale lock file is rewritten, and the hook fails so you can stage it;
- a missing lock file is created, and the hook fails until you add it to git (as does an existing lock file that isn't added).
Requires uv on your PATH. It's fast on large repositories: --all-files
takes about 0.5 s on 7,000 Python files.
- id: uv-lock-script
files: ^scripts/.*\.py$ # optional, defaults to every Python fileRun the scripts with uv run --locked --script <script>.py, so a stale lock file fails instead of being
silently rewritten.
All the 1.x hooks were removed:
check-branch-name: use a GitHub ruleset with a Restrict branch names rule instead. It's enforced at push, so it can't be skipped locally. In Alma repositories, ask DevX to add the repository to the organization ruleset.check-file-changeandcheck-comments: no replacement.
See CONTRIBUTING.md.