From a2c620136be8e7f553b0f7f578d455798a661b56 Mon Sep 17 00:00:00 2001 From: Tsvika Shapira Date: Tue, 30 Sep 2025 11:56:20 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Replace=20pre-commit?= =?UTF-8?q?=20with=20prek=20for=20hook=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the project to use prek instead of pre-commit for managing git hooks. Prek is a faster Rust-based alternative to pre-commit that maintains compatibility with the same hook ecosystem. --- README.md | 2 +- project_name/CONTRIBUTING.md.jinja | 4 ++-- project_name/justfile.jinja | 12 ++++++------ project_name/pyproject.toml.jinja | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4e58596..5241f2f 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Sensible defaults for all included tools are provided. - Replaces Flake8, isort, pyupgrade, yesqa, pycln, and dozens of plugins - Static type checking with [MyPy](https://mypy-lang.org/) - Curated `.gitignore` file -- Formatting and linting run automatically on commit via [pre-commit](https://pre-commit.com/) hooks: +- Formatting and linting run automatically on commit via [pre-commit](https://pre-commit.com/) hooks, running with [prek](https://prek.j178.dev/): - [EditorConfig](https://editorconfig.org/) for consistent formatting across editors - Spell checking with [codespell](https://github.com/codespell-project/codespell) and [typos](https://github.com/crate-ci/typos) - Markdown formatting with [Mdformat](https://mdformat.readthedocs.io/) diff --git a/project_name/CONTRIBUTING.md.jinja b/project_name/CONTRIBUTING.md.jinja index e06ce1e..a658f82 100644 --- a/project_name/CONTRIBUTING.md.jinja +++ b/project_name/CONTRIBUTING.md.jinja @@ -50,7 +50,7 @@ Ready to get started? Follow the development setup below. - **Lint code**: `uv run just lint` (runs all the linting tools) - **Format and lint code**: `uv run just quick-tools` (runs quick formatting and linting tools) - **Run tests**: `uv run just test` (runs `pytest`) -- **Run pre-commit tests**: `uv run pre-commit run`. This also runs on each commit. +- **Run pre-commit tests**: `uv run prek run`. This also runs on each commit. - **Run all checks**: `uv run just format lint test` ### Running Individual Tools @@ -62,7 +62,7 @@ You can run specific tools directly: uv run ruff check uv run mypy uv run pytest -uv run pre-commit run +uv run prek run ``` [how-to-contribute]: https://opensource.guide/how-to-contribute/ diff --git a/project_name/justfile.jinja b/project_name/justfile.jinja index 0a99d6d..367982c 100644 --- a/project_name/justfile.jinja +++ b/project_name/justfile.jinja @@ -25,7 +25,7 @@ init: && prepare # Setup the project after cloning prepare: - uv run pre-commit install --install-hooks + uv run prek install --install-hooks ### dependencies ### @@ -37,7 +37,7 @@ deps-list-outdated: # Update all dependencies deps-update: && deps-list-outdated uv sync --upgrade - uv run pre-commit autoupdate -j 0 | grep -v 'appears to be a mutable reference' + uv run prek autoupdate -j 0 | grep -v 'appears to be a mutable reference' uvx sync-with-uv uvx sync-pre-commit-deps --yaml-mapping 2 --yaml-sequence 4 --yaml-offset 2 .pre-commit-config.yaml || { \ echo "Note: '.pre-commit-config.yaml' changed, and might lost its formatting." \ @@ -82,10 +82,10 @@ format: {%- elif format_tool == "ruff" %} uv run ruff format {%- endif %} - uv run pre-commit run --all-files blacken-docs - uv run pre-commit run --all-files mdformat + uv run prek run --all-files blacken-docs + uv run prek run --all-files mdformat {%- if jupyter_files == "strip_outputs" %} - uv run pre-commit run --all-files nbstripout + uv run prek run --all-files nbstripout {%- endif %} # Run linters @@ -93,7 +93,7 @@ lint: uv run ruff check uv run --exact --all-extras --no-default-groups --group typing --group test -- dmypy run uv run --exact --all-extras --all-groups --with deptry -- deptry src/ - uv run --exact pre-commit run --all-files + uv run --exact prek run --all-files # Run Pylint (slow, not used in other tasks) pylint: diff --git a/project_name/pyproject.toml.jinja b/project_name/pyproject.toml.jinja index dc4e4b2..7844dce 100644 --- a/project_name/pyproject.toml.jinja +++ b/project_name/pyproject.toml.jinja @@ -71,7 +71,7 @@ dependencies = [ dev = [ ## used in the justfile "rust-just ~=1.0", - "pre-commit ~=4.0", + "prek ~=0.3.0", "black{% if contains_jupyter_files %}[jupyter]{% endif %} ~=26.1", "ruff ~=0.15.0", ## can be used for debug From 36b3b50ac14a49c65f236a44a9c76cf6cd9a7593 Mon Sep 17 00:00:00 2001 From: Tsvika Shapira Date: Mon, 27 Apr 2026 23:53:01 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=94=A7=20Use=20canonical=20`prek=20au?= =?UTF-8?q?to-update`=20command=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prek's docs use the hyphenated form; the unhyphenated `autoupdate` remains accepted for pre-commit compatibility but the new flags (`--cooldown-days`, `--check`) are documented only on `auto-update`. Co-Authored-By: Claude Opus 4.7 (1M context) --- project_name/justfile.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_name/justfile.jinja b/project_name/justfile.jinja index 367982c..e82d493 100644 --- a/project_name/justfile.jinja +++ b/project_name/justfile.jinja @@ -37,7 +37,7 @@ deps-list-outdated: # Update all dependencies deps-update: && deps-list-outdated uv sync --upgrade - uv run prek autoupdate -j 0 | grep -v 'appears to be a mutable reference' + uv run prek auto-update -j 0 | grep -v 'appears to be a mutable reference' uvx sync-with-uv uvx sync-pre-commit-deps --yaml-mapping 2 --yaml-sequence 4 --yaml-offset 2 .pre-commit-config.yaml || { \ echo "Note: '.pre-commit-config.yaml' changed, and might lost its formatting." \ From 2fb609e53300acc18c9cbcad56fdc6ecbc807feb Mon Sep 17 00:00:00 2001 From: Tsvika Shapira Date: Mon, 27 Apr 2026 23:54:01 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=91=B7=20Use=20j178/prek-action=20ins?= =?UTF-8?q?tead=20of=20pre-commit/action=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The native prek action runs `prek run --all-files` directly, avoiding the pre-commit/action wrapper now that the project has migrated to prek. Co-Authored-By: Claude Opus 4.7 (1M context) --- project_name/.github/workflows/ci.yml.jinja | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project_name/.github/workflows/ci.yml.jinja b/project_name/.github/workflows/ci.yml.jinja index fc81508..0c125c3 100644 --- a/project_name/.github/workflows/ci.yml.jinja +++ b/project_name/.github/workflows/ci.yml.jinja @@ -46,7 +46,7 @@ jobs: persist-credentials: false - uses: astral-sh/ruff-action@0ce1b0bf8b818ef400413f810f8a11cdbda0034b # v4.0.0 - pre-commit: + prek: env: COLUMNS: 120 runs-on: ubuntu-latest @@ -54,7 +54,7 @@ jobs: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: persist-credentials: false - - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 + - uses: j178/prek-action@cbc2f23eb5539cf20d82d1aabd0d0ecbcc56f4e3 # v2 mypy: runs-on: ubuntu-latest @@ -272,7 +272,7 @@ jobs: needs: - format-python - ruff-check - - pre-commit + - prek - mypy - dependencies - test From fcdef99adc6ec01ec4eda2fd0a50c7015e6eb90d Mon Sep 17 00:00:00 2001 From: Tsvika Shapira Date: Mon, 27 Apr 2026 23:59:23 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=8E=A8=20Drop=20redundant=20flags=20f?= =?UTF-8?q?rom=20prek=20auto-update=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `-j` defaults to `0` in prek (auto-detect cpu count) so it can be omitted. The `mutable reference` grep filter targeted a pre-commit-only warning that prek does not emit. Co-Authored-By: Claude Opus 4.7 (1M context) --- project_name/justfile.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_name/justfile.jinja b/project_name/justfile.jinja index e82d493..7f0ec97 100644 --- a/project_name/justfile.jinja +++ b/project_name/justfile.jinja @@ -37,7 +37,7 @@ deps-list-outdated: # Update all dependencies deps-update: && deps-list-outdated uv sync --upgrade - uv run prek auto-update -j 0 | grep -v 'appears to be a mutable reference' + uv run prek auto-update uvx sync-with-uv uvx sync-pre-commit-deps --yaml-mapping 2 --yaml-sequence 4 --yaml-offset 2 .pre-commit-config.yaml || { \ echo "Note: '.pre-commit-config.yaml' changed, and might lost its formatting." \