Repository navigation
chore(dev): add prek git hooks for Python, ruff, uv and Django - #249
Merged
Merged
Conversation
Add prek (Rust reimplementation of pre-commit) to the dev dependency group and a .pre-commit-config.yaml with: - pre-commit-hooks: whitespace, EOF, line endings, YAML/TOML/JSON syntax, merge conflicts, large files, debug statements, private keys - uv-lock to keep uv.lock in sync with pyproject.toml - django-upgrade targeting Django 6.0 - local hooks running ruff check/format, `manage.py check` and a missing migrations check through `uv run`, so the versions come from uv.lock Vendored static assets (Bootstrap, Font Awesome, SmartMenus) are excluded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mass fixes from the trailing-whitespace and end-of-file-fixer hooks on the first `prek run --all-files`. Whitespace only, no behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mass fixes from the django-upgrade hook (--target-version 6.0), followed by ruff merging the resulting imports: - drop USE_L10N, removed in Django 5.0 (localization is always on) - import include from django.urls instead of django.conf.urls - use path() instead of re_path() for the plain admin/ and documents/ prefixes - register sponsors admin classes with the @admin.register decorator No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a dedicated prek job, in parallel with the test job, running every hook with the versions locked in uv.lock. Hook environments are cached per .pre-commit-config.yaml hash. The existing ruff, pip-audit and test steps are kept unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Enable the pre-commit manager (disabled by default in Renovate), group hook revision bumps in a weekly PR and keep the uv-lock hook in the uv group so it moves together with the uv dev dependency, Dockerfile and mise.toml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prek is a developer tool installed once per machine (mise, Homebrew or uv tool), not a project dependency: drop it from the dev group and uv.lock. CI installs it with j178/prek-action, which also caches the hook environments. Docs now use `prek` directly instead of `uv run prek`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prek is a machine tool like uv: pin it in mise.toml so `mise install` provides it, and document mise as the default way to get it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
List uv and prek as prerequisites (pinned in mise.toml) and add the `uv sync --all-groups && prek install` step to the Docker and local setup guides in README.md, CONTRIBUTING.md and DEVELOPMENT.md: the hooks run on the host even when developing with Docker. README.md gets a Git Hooks section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
matrixise
force-pushed
the
chore/prek-hooks
branch
from
September 25, 2026 06:54
aebebd4 to
5e079e6
Compare
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Set up prek, a Rust drop-in replacement for pre-commit that reads
.pre-commit-config.yaml, with a base set of hooks for Python, ruff, uv and Django.Installation choice
Like uv, prek is a machine tool, not a project dependency: it is not in
pyproject.tomlnoruv.lock. It is pinned inmise.tomlnext to uv (mise install), and can also be installed withbrew install prekoruv tool install prek. Then runprek installin the clone. The ruff and Django hooks still need the project environment (uv sync --all-groups).Hooks
mise.tomland the dev group)--target-version 6.0uv run --frozen: ruff check--fix, ruff format,manage.py check,manage.py makemigrations --check --dry-runRuff runs as a
localhook instead ofastral-sh/ruff-pre-commit: the version comes fromuv.lock, so the hook, CI and the editor cannot drift, and there is no rev to keep aligned withpyproject.toml.The Django hooks unset
DATABASE_URLso they always use the local SQLite database, even when a shell exports a remoteDATABASE_URL.Vendored assets under
pythonie/core/static/{css,fonts,js}(Bootstrap, Font Awesome, SmartMenus) are excluded.Not added: djLint. On the current templates it reports 12 lint errors (missing
lang/alt,typeon scripts, orphan tag, tag spacing) and would reformat all 13 templates. It is worth a follow-up PR that fixes the templates first.Fixes from the first
prek run --all-files(separate commits)style:whitespace/EOF only:.coveragerc,CLAUDE.md,development.env,base.html,core/meetup.html,core/segment.html,navbar_tree.htmlrefactor:django-upgrade: dropUSE_L10N(removed in Django 5.0),includefromdjango.urls,path()instead ofre_path()for theadmin/anddocuments/prefixes,@admin.registerinsponsors/admin.pyNo behavior change.
CI
New
prekjob intest.yml, parallel to the existingtestjob:uv sync --all-groups(for the local ruff and Django hooks), thenj178/prek-action@v3.0.0, which installs prek, caches the hook environments and runsprek run --show-diff-on-failure --all-files. The existing ruff, pip-audit and test steps are kept unchanged: the ruff steps overlap with the hooks but take under a second and remain the explicit gates of thetestjob.Renovate
The
pre-commitmanager is disabled by default in Renovate: it is now enabled. Hook revisions are grouped in a weekly "pre-commit hooks" PR, andastral-sh/uv-pre-commitjoins the existinguvgroup so it moves together with the uv dev dependency, Dockerfile andmise.toml.Docs
README.md,CONTRIBUTING.md,DEVELOPMENT.mdandCLAUDE.md: uv and prek listed as prerequisites, auv sync --all-groups && prek installstep in both the Docker and the local setup guides (the hooks run on the host even with Docker), usage, and emergency bypass (SKIP=<hook-id>,git commit --no-verify).Test plan
prek run --all-files: all hooks passuv run ruff format --check pythonieanduv run ruff check pythonieuv run python pythonie/manage.py test pythonie --settings=pythonie.settings.tests(SQLite): 7 tests OKrenovate-config-validator renovate.json🤖 Generated with Claude Code