Skip to content

About

Alma pre-commit-hooks

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Alma pre-commit hooks

Shared pre-commit hooks for Alma repositories. They work with both prek and pre-commit.

Usage

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-script

Always 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.

Hooks

Hook Description
uv-lock-script Keeps the lock files of PEP 723 scripts up to date

uv-lock-script

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 file

Run the scripts with uv run --locked --script <script>.py, so a stale lock file fails instead of being silently rewritten.

Upgrading from 1.x

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-change and check-comments: no replacement.

Contributing

See CONTRIBUTING.md.

About

Alma pre-commit-hooks

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages