From de2cfc1c210ce33f02c9aa917826a425f1d73b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Fri, 25 Sep 2026 08:25:29 +0200 Subject: [PATCH 1/9] chore(dev): add prek git hooks for Python, ruff, uv and Django 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 --- .pre-commit-config.yaml | 79 +++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 1 + uv.lock | 18 ++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8e97b6d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,79 @@ +# Git hooks, run with prek (https://github.com/j178/prek), a drop-in +# replacement for pre-commit that reads this same file. +# +# uv sync --all-groups # prek is part of the dev dependency group +# uv run prek install # install the git hook for this clone +# uv run prek run --all-files # run every hook on the whole repository +# +# Revisions are pinned to tags and kept up to date by Renovate. + +# Vendored third-party assets (Bootstrap, Font Awesome, SmartMenus) are kept +# byte-for-byte identical to upstream. +exclude: | + (?x)^( + pythonie/core/static/(css|fonts|js)/.* + )$ + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=lf] + - id: check-yaml + - id: check-toml + - id: check-json + - id: check-merge-conflict + - id: check-case-conflict + - id: check-added-large-files + args: [--maxkb=500] + - id: debug-statements + - id: detect-private-key + + # Keeps uv.lock in sync with pyproject.toml. The rev tracks the uv version + # pinned in mise.toml and the dev dependency group (Renovate "uv" group). + - repo: https://github.com/astral-sh/uv-pre-commit + rev: 0.12.19 + hooks: + - id: uv-lock + + - repo: https://github.com/adamchainz/django-upgrade + rev: 1.32.0 + hooks: + - id: django-upgrade + args: [--target-version, "6.0"] + + # Ruff and Django checks run through `uv run` so they use the exact versions + # locked in uv.lock (the same ones CI uses): there is no second ruff version + # to keep in sync with pyproject.toml. + # The Django hooks unset DATABASE_URL so they always run against the local + # SQLite database, never against a remote one exported in the shell. + - repo: local + hooks: + - id: ruff-check + name: ruff check + entry: uv run --frozen ruff check --fix --force-exclude + language: system + types_or: [python, pyi] + require_serial: true + - id: ruff-format + name: ruff format + entry: uv run --frozen ruff format --force-exclude + language: system + types_or: [python, pyi] + require_serial: true + - id: django-check + name: django system checks + entry: env -u DATABASE_URL uv run --frozen python pythonie/manage.py check --settings=pythonie.settings.tests + language: system + files: ^pythonie/.*\.py$ + pass_filenames: false + - id: django-missing-migrations + name: django missing migrations + entry: env -u DATABASE_URL uv run --frozen python pythonie/manage.py makemigrations --check --dry-run --settings=pythonie.settings.tests + language: system + files: ^pythonie/.*\.py$ + pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index bd82add..412c3b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dev = [ "model_mommy>=2.0.0", "pip-audit>=2.10.1", "pipdeptree>=4.2.5", + "prek>=0.5.3", "ruff==0.16.9", # pinned: ruff minor releases change the default lint rule set "uv>=0.12.19", "wagtail-factories>=4.5.0", diff --git a/uv.lock b/uv.lock index 8021321..4795151 100644 --- a/uv.lock +++ b/uv.lock @@ -1013,6 +1013,22 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/2b/69de6317fbf48865bb12aa56c9cfcfff46b3add0cd45250725d96146dce0/platformdirs-4.11.12-py3-none-any.whl", hash = "sha256:b1ba966ac76153d9985a0787ffab951e7c18416189873d4e4ddb2c8a04a0a254", size = 24976, upload-time = "2026-09-22T01:02:35.742Z" }, ] +[[package]] +name = "prek" +version = "0.5.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/54/93/d1e5afc996b9fde04d71c37fd28bdd404e54daf1da6c76b883c5cdbdb411/prek-0.5.3.tar.gz", hash = "sha256:06d88bed9a5b2886cd3796957e4cecf05fa9b06724b625df31dbf0a48ff2330c", size = 551929, upload-time = "2026-09-13T08:38:37.823Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/db/5d/8731dc49cb5424d37424db3ea2f3ff6a0b20caa971db72796e822ce48b24/prek-0.5.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:2d7240c5e6a996ef5bebe5d57d43049803e41c225b343681c020bf0c87dab2b2", size = 6003518, upload-time = "2026-09-13T08:38:20.584Z" }, + { url = "https://files.pythonhosted.org/packages/51/45/ca413aefb3ea2411bbf0adb6eebfac1e9bfc5ac7679dbe26336fc651c347/prek-0.5.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:1dd6df8235ca361dbbeec89c305ccb41a138088a2fc548484b4cb89f66a80d20", size = 5538754, upload-time = "2026-09-13T08:38:23.004Z" }, + { url = "https://files.pythonhosted.org/packages/dc/92/874d58ba40d2fe7cfec2789ae8bf415f3751666ad5c59928821fe53c3c01/prek-0.5.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:61ff791bb850ba52cc0d86576498df7e1bd1e9ed20df63dae113a4a6aa495e19", size = 5841568, upload-time = "2026-09-13T08:38:25.008Z" }, + { url = "https://files.pythonhosted.org/packages/8f/40/167037b8eef75f6f036c60ff7e93f42defebb7c3733677e2f30e5a479257/prek-0.5.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a863379a2668c4ef079d820ffd5b14073145380dfbe0e70fef498dc73c568f86", size = 6226960, upload-time = "2026-09-13T08:38:26.788Z" }, + { url = "https://files.pythonhosted.org/packages/42/9a/bfcd3c1fe1fdefee8dc144a92c4b0b93b59f31c7df60ee1720c49223a90a/prek-0.5.3-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:086d1b77557f0a089568dc5b93c22ccd793351524f3eeb29d36781421a350e72", size = 5854832, upload-time = "2026-09-13T08:38:28.954Z" }, + { url = "https://files.pythonhosted.org/packages/15/41/1450b995b18bbf0d8ab65016860198052baad5c79c231151fa1dcca4a2de/prek-0.5.3-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:4f09b947255124e9591a7f7ef16eb5340a36ba94a275d788d7ea804fab35f0e2", size = 6343055, upload-time = "2026-09-13T08:38:30.96Z" }, + { url = "https://files.pythonhosted.org/packages/9c/e8/8f45950b8a8ddcf22efc7183e9d6b1d7e30373229ff7d9e56f918a55922c/prek-0.5.3-py3-none-win_amd64.whl", hash = "sha256:5b74a9742c3e8f8688d5dad1439688f112e2e1746fcb91016015dae38df3eb42", size = 5744293, upload-time = "2026-09-13T08:38:33.104Z" }, + { url = "https://files.pythonhosted.org/packages/24/cd/ce637f4b6cc6c583516dc16b539408dab593672f7c6fe7723a37caf378ff/prek-0.5.3-py3-none-win_arm64.whl", hash = "sha256:20d92aef53a5e237f4659ecc6669c0fbc98a1b83f0e2476530400a72d42ca390", size = 5512958, upload-time = "2026-09-13T08:38:36.123Z" }, +] + [[package]] name = "psycopg" version = "3.3.6" @@ -1180,6 +1196,7 @@ dev = [ { name = "model-mommy" }, { name = "pip-audit" }, { name = "pipdeptree" }, + { name = "prek" }, { name = "ruff" }, { name = "uv" }, { name = "wagtail-factories" }, @@ -1222,6 +1239,7 @@ dev = [ { name = "model-mommy", specifier = ">=2.0.0" }, { name = "pip-audit", specifier = ">=2.10.1" }, { name = "pipdeptree", specifier = ">=4.2.5" }, + { name = "prek", specifier = ">=0.5.3" }, { name = "ruff", specifier = "==0.16.9" }, { name = "uv", specifier = ">=0.12.19" }, { name = "wagtail-factories", specifier = ">=4.5.0" }, From bfc05073c87c03822583a0c7c7d872ffc2c2a7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Fri, 25 Sep 2026 08:25:35 +0200 Subject: [PATCH 2/9] style: fix trailing whitespace and end of file newlines 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 --- .coveragerc | 1 - CLAUDE.md | 2 +- development.env | 1 - pythonie/core/templates/base.html | 4 ++-- pythonie/core/templates/core/meetup.html | 2 +- pythonie/core/templates/core/segment.html | 2 +- pythonie/core/templates/navbar_tree.html | 8 +++----- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.coveragerc b/.coveragerc index 86a32ae..e914860 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,3 @@ [run] branch = True source = pythonie - diff --git a/CLAUDE.md b/CLAUDE.md index fc0b6b3..4ff5c34 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -270,4 +270,4 @@ All documentation and code comments must be written in English to ensure all con ### Git Commits -When creating git commits, do not include any mention of Claude, Claude Code, or AI assistance in commit messages. Commit messages should focus solely on describing the changes made, without attribution to the tool used to make them. \ No newline at end of file +When creating git commits, do not include any mention of Claude, Claude Code, or AI assistance in commit messages. Commit messages should focus solely on describing the changes made, without attribution to the tool used to make them. diff --git a/development.env b/development.env index 94ad002..f0c13cb 100644 --- a/development.env +++ b/development.env @@ -4,4 +4,3 @@ PGUSER=postgres PGPASSWORD=pythonie PGHOST=postgres REDISCLOUD_URL=redis://redis:6379 - diff --git a/pythonie/core/templates/base.html b/pythonie/core/templates/base.html index dbc01c2..073a166 100644 --- a/pythonie/core/templates/base.html +++ b/pythonie/core/templates/base.html @@ -46,10 +46,10 @@ {% compress css %} - + - + diff --git a/pythonie/core/templates/core/meetup.html b/pythonie/core/templates/core/meetup.html index 7366501..e157bbf 100644 --- a/pythonie/core/templates/core/meetup.html +++ b/pythonie/core/templates/core/meetup.html @@ -17,7 +17,7 @@
Sponsors:
diff --git a/pythonie/core/templates/navbar_tree.html b/pythonie/core/templates/navbar_tree.html index 9b1f0fc..1a4cb29 100644 --- a/pythonie/core/templates/navbar_tree.html +++ b/pythonie/core/templates/navbar_tree.html @@ -10,9 +10,9 @@