Skip to content

build: migrate from pre-commit to prek - #40

Open
hasansezertasan wants to merge 1 commit into
ci/zizmorfrom
build/prek
Open

build: migrate from pre-commit to prek#40
hasansezertasan wants to merge 1 commit into
ci/zizmorfrom
build/prek

Conversation

@hasansezertasan

@hasansezertasan hasansezertasan commented Jul 23, 2026

Copy link
Copy Markdown
Member

Description

Migrates the hook runner from pre-commit to prek — a faster, Rust-based, single-binary drop-in reimplementation. .pre-commit-config.yaml is unchanged; prek reads it directly, and every existing hook (ruff, black, codespell, mypy, slotscheck, zizmor, uv-lock, …) runs as-is.

Changes

  • CI (ci.yaml validate job): pip install prek + prek run --all-files instead of pre-commit; cache path/key moved to ~/.cache/prek.
  • Makefile: make lintprek run; make upgradeprek update (prek's equivalent of pre-commit autoupdate).
  • pyproject.toml lint group: pre-commitprek. Lockfile regenerated (drops virtualenv/python-discovery).
  • README: usage + local-development instructions updated.

CLI compatibility verified

prek run supports --all-files, --show-diff-on-failure, and --color (same flags as pre-commit); prek validate-config .pre-commit-config.yamlAll configs are valid.

Notes for reviewers

Closes

Summary by Sourcery

Migrate linting hook runner from pre-commit to prek across CI, developer tooling, and documentation while keeping existing hooks and config intact.

Enhancements:

  • Switch CI workflow lint job to use prek for running hooks with updated cache configuration.
  • Update Makefile lint and upgrade targets to invoke prek for running and updating hooks.
  • Replace pre-commit with prek in the lint dependency group and regenerate the uv lockfile to reflect the new tooling dependency.
  • Refresh README instructions to reference prek for installing and running lint hooks.

@hasansezertasan hasansezertasan added the infra This is Infrastructure related label Jul 23, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Migrates the project from using pre-commit to prek for running the existing hook set in CI, local dev tooling, and dependency management, while keeping .pre-commit-config.yaml as the source of hook definitions.

Flow diagram for CI validate job using prek instead of pre-commit

flowchart TD
  A[GitHub Actions validate job] --> B[Set up Python 3.11]
  B --> C[Install prek via pip]
  C --> D[Restore/save cache at ~/.cache/prek]
  D --> E[Run prek run --show-diff-on-failure --color=always --all-files]
  E --> F[Hooks from .pre-commit-config.yaml execute]
Loading

Flow diagram for local lint and upgrade using prek

flowchart TD
  subgraph Lint_flow
    Dev[Developer] --> M[make lint]
    M --> U1[uv run prek run --all-files]
    U1 --> H1[Hooks from .pre-commit-config.yaml execute]
  end

  subgraph Upgrade_flow
    Dev2[Developer] --> MU[make upgrade]
    MU --> U2[uv lock --upgrade and uv sync]
    U2 --> P[uv run prek update]
    P --> H2[Hook revisions updated in .pre-commit-config.yaml]
  end
Loading

File-Level Changes

Change Details Files
Switch CI lint/validation job from pre-commit to prek while preserving behavior and cache efficiency.
  • Replace installation step to install prek via pip instead of pre-commit and remove pre-commit install invocation.
  • Update cache step to use ~/.cache/prek and a cache key prefixed with 'prek-' while still hashing .pre-commit-config.yaml.
  • Change the lint execution command from pre-commit run with flags to prek run with equivalent flags, keeping PYTHONPATH behavior unchanged.
  • Rename CI step labels from pre-commit wording to prek wording for clarity.
.github/workflows/ci.yaml
Update local developer workflows in the Makefile to invoke prek instead of pre-commit for linting and hook updates.
  • Change the upgrade target to run uv run prek update instead of pre-commit autoupdate, and adjust its log message.
  • Change the lint target to run uv run prek run --all-files with updated echo messaging to reference prek instead of pre-commit.
Makefile
Update documentation and dependency declarations to reference prek instead of pre-commit and regenerate the uv lockfile accordingly.
  • Update README usage and local development examples to show prek install/update and prek-based lint commands instead of pre-commit equivalents.
  • Replace pre-commit with prek in the pyproject.toml lint dependency group, pinning prek>=0.4.10.
  • Regenerate uv.lock to reflect the switch from pre-commit to prek and the resulting dependency graph changes.
README.md
pyproject.toml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/ci.yaml" line_range="28-33" />
<code_context>

-      - name: Load cached Pre-Commit Dependencies
-        id: cached-pre-commit-dependencies
+      - name: Load cached prek dependencies
+        id: cached-prek-dependencies
         uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3
         with:
-          path: ~/.cache/pre-commit/
-          key: pre-commit-|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
+          path: ~/.cache/prek/
+          key: prek-|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

-      - name: Execute Pre-Commit
</code_context>
<issue_to_address>
**issue (performance):** Double-check that the prek cache path and key match its actual cache layout and config file.

Since the path is now `~/.cache/prek/` but the key still hashes `.pre-commit-config.yaml`, please verify that prek actually uses `~/.cache/prek/` and that `.pre-commit-config.yaml` is still the canonical config for cache invalidation (and not, for example, `prek.toml` or `pyproject.toml`).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/ci.yaml
Comment on lines +28 to +33
- name: Load cached prek dependencies
id: cached-prek-dependencies
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3
with:
path: ~/.cache/pre-commit/
key: pre-commit-|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/prek/
key: prek-|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (performance): Double-check that the prek cache path and key match its actual cache layout and config file.

Since the path is now ~/.cache/prek/ but the key still hashes .pre-commit-config.yaml, please verify that prek actually uses ~/.cache/prek/ and that .pre-commit-config.yaml is still the canonical config for cache invalidation (and not, for example, prek.toml or pyproject.toml).

hasansezertasan added a commit that referenced this pull request Jul 23, 2026
Update the hook-runner references from pre-commit to prek, matching
the migration in #20 (#40).

Refs #20
Replace pre-commit with prek (a faster, Rust-based drop-in) as the
hook runner. The .pre-commit-config.yaml is unchanged - prek reads it
directly.

- ci.yaml validate job installs and runs prek instead of pre-commit
  (cache path/key updated to ~/.cache/prek).
- Makefile: 'lint' runs 'prek run', 'upgrade' runs 'prek update'
  (prek's equivalent of 'pre-commit autoupdate').
- lint dependency-group: pre-commit -> prek.
- README local-development and usage instructions updated.

Closes #20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra This is Infrastructure related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant