Swap pre-commit for prek#42
Conversation
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>
There was a problem hiding this comment.
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 updatesuv.lock). - Removes
.pre-commit-config.yamland introducesprek.tomlwith 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.
| 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`: |
There was a problem hiding this comment.
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.
|
|
||
| - 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 |
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>
|
Note, if we want pre-commit ci autofix behavior back, we can always add the flows in a follow up. |
|
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. |
|
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. |
|
@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. |
|
@LeonarddeR wrote:
Thanks. I'll wait for your work if you create those followup pull requests. |
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.yamlto prek's nativeprek.toml. Maintainers confirmed disabling pre-commit.ci on this repo is preferred.Changes
pyproject.toml: dev dependencypre-commit==4.2.0->prek==0.4.8(+uv.lock)..pre-commit-config.yamlremoved, replaced byprek.toml(generated withprek util yaml-to-toml, then hand-adjusted).ci:block and thecheck-pre-commit-ci-confighook.pre-commit-hooksto prek'sbuiltinrepo (no clone / norev).check-ast,debug-statementsandcheck-illegal-windows-nameson the upstreampre-commit-hooksrepo: the first two have no builtin equivalent, and the builtincheck-illegal-windows-namesonly matches files that already have illegal names, whichcheck-hooks-applyflags as unused on a clean repo.build_addon.yml): the "Code checks" step now runsuv run prek run --all-files(the
SKIPenv 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 runlocally,prek auto-update). The PR gate inbuild_addon.ymlremains 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