Skip to content

Swap pre-commit for prek#42

Open
LeonarddeR wants to merge 3 commits into
nvaccess:masterfrom
LeonarddeR:prek
Open

Swap pre-commit for prek#42
LeonarddeR wants to merge 3 commits into
nvaccess:masterfrom
LeonarddeR:prek

Conversation

@LeonarddeR

Copy link
Copy Markdown

Closes #28.

Summary

Switches the template from pre-commit + the
pre-commit.ci service to prek,
a fast, drop-in alternative written in Rust. As discussed in #28, this goes further than
NVDA's swap by also migrating the config from .pre-commit-config.yaml to prek's native
prek.toml. Maintainers confirmed disabling pre-commit.ci on this repo is preferred.

Changes

  • pyproject.toml: dev dependency pre-commit==4.2.0 -> prek==0.4.8 (+ uv.lock).
  • Config: .pre-commit-config.yaml removed, replaced by prek.toml (generated with
    prek util yaml-to-toml, then hand-adjusted).
    • Dropped the pre-commit.ci ci: block and the check-pre-commit-ci-config hook.
    • Moved the file-oriented pre-commit-hooks to prek's builtin repo (no clone / no rev).
    • Kept check-ast, debug-statements and check-illegal-windows-names on the upstream
      pre-commit-hooks repo: the first two have no builtin equivalent, and the builtin
      check-illegal-windows-names only matches files that already have illegal names, which
      check-hooks-apply flags as unused on a clean repo.
  • CI (build_addon.yml): the "Code checks" step now runs uv run prek run --all-files
    (the SKIP env var is still honored).
  • readme.md: replaced the pre-commit.ci recommendation with prek usage
    (uv run prek install / uv run prek run --all-files).

Note on dropping pre-commit.ci

pre-commit.ci provided autofix commits and hook autoupdate. Those are not replaced here --
they become manual (prek run locally, prek auto-update). The PR gate in build_addon.yml
remains the automated check.

Verification

  • uv lock && uv sync -- prek installs, pre-commit removed.
  • uv run prek run --all-files -- all hooks pass.
  • uv run prek install -- git hook installs.

🤖 Generated with Claude Code

Replace pre-commit with prek (a fast, drop-in alternative) and drop
pre-commit.ci support. Convert .pre-commit-config.yaml to the native
prek.toml, dropping the pre-commit.ci `ci:` block and the
check-pre-commit-ci-config hook. Move the file-oriented pre-commit-hooks
to prek's builtin repo. check-ast, debug-statements and
check-illegal-windows-names stay on the upstream repo: the first two have
no builtin equivalent, and the builtin check-illegal-windows-names only
matches already-illegal filenames, which check-hooks-apply flags as unused
on a clean repo. Update the CI gate and readme.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 17:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the template’s git-hook-based lint/format/type-check gate from pre-commit + pre-commit.ci to prek, including moving configuration from .pre-commit-config.yaml to prek.toml, and updating CI/docs accordingly.

Changes:

  • Replaces the pre-commit dependency with prek==0.4.8 (and updates uv.lock).
  • Removes .pre-commit-config.yaml and introduces prek.toml with equivalent hook configuration.
  • Updates GitHub Actions and documentation to run prek (uv run prek run --all-files).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Swaps the dev tooling dependency from pre-commit to prek.
uv.lock Lockfile update reflecting removal of pre-commit and addition of prek.
prek.toml New prek-native hook configuration replacing the prior YAML config.
.pre-commit-config.yaml Removed in favor of prek.toml.
.github/workflows/build_addon.yml CI “Code checks” now runs prek instead of pre-commit.
readme.md Documentation updated to recommend/use prek commands instead of pre-commit.ci.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread prek.toml Outdated
Comment thread readme.md
It's recommended to install pre-commit.ci [pre-commit](https://pre-commit.ci) on personal GitHub accounts.
Then, you can choose if pre-commit will be used in all or just in selected repos.
This template uses [prek](https://github.com/j178/prek) (a fast, drop-in alternative to pre-commit) to run linting, formatting, and type-checking hooks, configured in `prek.toml`.
`prek` is included as a development dependency, so you can run it through `uv`:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

prek (and the other tooling) is now declared in a PEP 735 dev dependency group rather than [project].dependencies, so the wording is accurate: it is a real development dependency.

Comment thread .github/workflows/build_addon.yml Outdated

- name: Code checks
run: export SKIP=no-commit-to-branch; uv run pre-commit run --all-files
run: export SKIP=no-commit-to-branch; uv run prek run --all-files

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Switched to PREK_SKIP.

LeonarddeR and others added 2 commits July 10, 2026 19:20
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Address PR review: this package ships nothing at runtime, so all
dependencies are tooling. Move them from [project].dependencies into PEP
735 [dependency-groups] (build, l10n, lint), with a dev group that
includes all three. uv sync installs the dev group by default, so CI is
unaffected.

Use prek's native PREK_SKIP env var instead of the SKIP compatibility
fallback in the build workflow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LeonarddeR

Copy link
Copy Markdown
Author

Note, if we want pre-commit ci autofix behavior back, we can always add the flows in a follow up.

@nvdaes

nvdaes commented Jul 11, 2026

Copy link
Copy Markdown

Thanks @LeonarddeR . Luckily I have looked at this repo since I was also working for this and testing. I'll merge this PR on clipContentsDesigner add-on and I'll close the PR where I was testing.
I like a lot this work.

@nvdaes

nvdaes commented Jul 11, 2026

Copy link
Copy Markdown

Sorry @LeonarddeR , I started investigating prek mostly yesterday. Previously I read about it but not deeply, so maybe this doesn't make sense. In my work in PR 91 of clipContentsDesigner, I used the prek GitHub Action to push changes to the branch, ensuring that workflows aren't run if the author is GitHub Actions Bot, to avoid re-running workflows when GitHub Actions pushes fixes. Also, I used [update] with colldown_days = 7.
These approaches are wrong, right? Just to confirm, since I don't have experience with prek.

@LeonarddeR

Copy link
Copy Markdown
Author

@nvdaes No I definitely think these approaches are right. However when we want to add prek autofixing with github action and also autop updating of hooks, I think we should do that in follow up pull requests.

@nvdaes

nvdaes commented Jul 11, 2026

Copy link
Copy Markdown

@LeonarddeR wrote:

I definitely think these approaches are right. However when we want to add prek autofixing with github action and also autop updating of hooks, I think we should do that in follow

Thanks. I'll wait for your work if you create those followup pull requests.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pre-commit in the workflow

3 participants