Skip to content

Add pre-commit: ruff, plus the rendered test templates linted as a sibling would (F11) - #29

Merged
SDNick484 merged 1 commit into
mainfrom
audit/pre-commit
Nov 10, 2026
Merged

SDNick484 merged 1 commit into
mainfrom
audit/pre-commit

Conversation

@SDNick484

Copy link
Copy Markdown
Owner

Refs #16 (F11).

Why

templates/ holds __PKG__, so ruff excludes it. Its rendered copies in tests/ are gitignored here, so ruff check . skips those as well. CI has linted them with --no-respect-gitignore since #25, but only after a push. This catches the problem at commit time instead.

Hooks (.pre-commit-config.yaml, in run order)

Hook Source Runs on
check-toml, check-yaml, check-merge-conflict, end-of-file-fixer, trailing-whitespace pre-commit/pre-commit-hooks v6.0.0 staged files (the tree already passes all five)
render-shared-tests local: python scripts/sync_shared.py --source . --package mcp_shared changes to templates/, shared.toml, the sync script, pyproject.toml
ruff-check, ruff-format astral-sh/ruff-pre-commit v0.17.4 (= the dev env's ruff) staged files
ruff-check-rendered-tests, ruff-format-rendered-tests the same two hooks via alias, args --no-respect-gitignore tests same filter as the render hook

The rendered-tests lint reuses ruff-pre-commit's hooks rather than a local hook, so ruff is pinned once. A local hook would need ruff in additional_dependencies, which Dependabot doesn't update: it skips local hooks.

Verified. A 130-column line added to templates/tests/test_tasks.py passes plain ruff check and fails both rendered-tests hooks with E501. That is exactly the #25 failure. pre-commit run --all-files passes on this branch.

Pinning and Dependabot

  • Revs are commit SHAs with # frozen: vX comments.
  • Dependabot has supported the pre-commit ecosystem since 2026-03 (changelog). It bumps the SHA and the comment together. It's added to .github/dependabot.yml, weekly and grouped like the other two ecosystems.

Other

  • pre-commit>=4 joins the dev extra.
  • README (Workflows) and CLAUDE.md (Commands) each get one line on pre-commit install.
  • CI is unchanged: it already runs the same checks.

Note for review

On main, pytest can fail locally on test_no_ipv6_survives_redact (::ffff:0.0.0.1) once hypothesis has drawn it, because the example database replays it. That's the existing flaky test fixed in #28, not this PR.

🤖 Generated with Claude Code

…bling would (F11)

The templates hold __PKG__, so ruff excludes templates/; their rendered copies
in tests/ are gitignored here, so `ruff check .` skips those too. CI lints them
with --no-respect-gitignore since #25, but only after a push. pre-commit now
catches it at commit time:

- render-shared-tests (local): sync_shared.py --source . --package mcp_shared,
  when templates/, shared.toml, the sync script or pyproject.toml change.
- ruff-check / ruff-format on the staged files, and the same two hooks again
  (aliases *-rendered-tests) with --no-respect-gitignore tests. Reusing
  ruff-pre-commit's hooks pins ruff once; a local hook would need its own
  ruff in additional_dependencies, which Dependabot doesn't update.
- pre-commit-hooks: check-toml, check-yaml, check-merge-conflict,
  end-of-file-fixer, trailing-whitespace (the tree already passes all five).

Revs are commit SHAs with "# frozen: vX" comments. Dependabot gains the
pre-commit ecosystem (GA 2026-03), which bumps SHA and comment together and
skips local hooks. pre-commit joins the dev extra; README and CLAUDE.md say
`pre-commit install`.

Checked: a 130-column line added to templates/tests/test_tasks.py passes the
plain ruff hook and fails both rendered-tests hooks (E501), the #25 failure.

Refs #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SDNick484
SDNick484 merged commit 09acf95 into main Nov 10, 2026
4 checks passed
@SDNick484
SDNick484 deleted the audit/pre-commit branch November 10, 2026 22:04
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