Skip to content

chore(dev): add pre-commit hooks mirroring the CI lint gate#3

Merged
thomas-villani merged 1 commit into
mainfrom
chore/pre-commit-hooks
Jun 15, 2026
Merged

chore(dev): add pre-commit hooks mirroring the CI lint gate#3
thomas-villani merged 1 commit into
mainfrom
chore/pre-commit-hooks

Conversation

@thomas-villani

Copy link
Copy Markdown
Owner

Why

PR #1 passed local ruff check but failed CI on ruff format --check — a separate CI step that wasn't in the documented quality gate (SPEC §13) or the local routine. This closes that gap so formatting issues are caught before they reach CI.

What

  • .pre-commit-config.yaml — local hooks running uv run ruff format and uv run ruff check --fix. Using uv run (rather than astral-sh/ruff-pre-commit, which pins its own ruff) means the hook, CI, and the ruff dev dependency all resolve to the same ruff — no version drift, which is the whole point.
  • pyproject.toml — add pre-commit>=3.5 to the dev extra.
  • SPEC.md §13 — add ruff format --check and mkdocs build --strict to the quality-gate list (both are CI-enforced but were missing), and document uv run pre-commit install.
  • README.md — document the hook in the dev-install section.

Setup is one command after uv sync --extra dev:

uv run pre-commit install

Verification

  • uv run pre-commit run --all-files: both hooks pass on the whole tree.
  • Sanity-checked the hooks actually catch a deliberately malformed file (ruff-format reformats it and fails the commit), then confirmed a clean tree passes.
  • ruff format --check / ruff check on docx_plus/ tests/: clean.

Note on the uv.lock diff

The line count is large but the change is additive only: pre-commit plus its transitive deps (cfgv, distlib, filelock, identify, nodeenv, virtualenv, …). No runtime dependency was re-resolved (verified: nothing removed from the lock); the bulk of the churn is a lock-format revision bump from the local uv being newer than what generated the original lock.

🤖 Generated with Claude Code

Root cause of the PR #1 CI failure: `ruff format --check` is a separate CI
step from `ruff check`, and only the latter was in the documented gate
(SPEC §13) and the local routine. Lint-clean code could still fail
formatting on CI.

- `.pre-commit-config.yaml` — local hooks running `uv run ruff format` and
  `uv run ruff check --fix`. Using `uv run` (not astral-sh/ruff-pre-commit)
  means the hook, CI, and the `ruff` dev dependency all resolve to the same
  ruff, so the hook can't drift from CI.
- pyproject: add `pre-commit>=3.5` to the dev extra.
- SPEC §13: add `ruff format --check` and `mkdocs build --strict` to the
  quality-gate list and document the `uv run pre-commit install` step.
- README: document the hook in the dev-install section.

uv.lock: additive only — pre-commit and its transitive deps (cfgv, distlib,
filelock, identify, nodeenv, virtualenv, ...). No runtime dep re-resolved;
the large line count is a lock-format `revision` bump from the local uv.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thomas-villani thomas-villani merged commit a381837 into main Jun 15, 2026
11 checks passed
@thomas-villani thomas-villani deleted the chore/pre-commit-hooks branch June 15, 2026 16:36
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.

1 participant