Skip to content
Prev Previous commit
Next Next commit
fix: Address review feedback on pre-commit hooks
- Format hook now runs both ruff check --fix AND ruff format
- Lint hook now runs both ruff check AND ruff format --check
- Template hook file filter now includes docs/roadmap.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
  • Loading branch information
2 people authored and ntkathole committed Feb 11, 2026
commit d2c57c108148068819356491bdd3fcb11f5412b2
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ repos:
- repo: local
hooks:
# File-aware format hook - only runs on changed Python files
# Runs both ruff check --fix and ruff format
- id: format-files
name: Format Changed Files
stages: [commit]
language: system
types: [python]
entry: uv run ruff check --fix
entry: bash -c 'uv run ruff check --fix "$@" && uv run ruff format "$@"' --
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 && in format-files pre-commit hook skips ruff format when unfixable lint violations exist

The format-files pre-commit hook entry uses && to chain ruff check --fix and ruff format. When ruff check --fix encounters lint violations that cannot be auto-fixed, it returns exit code 1, and the && operator prevents ruff format from executing. This means files with unfixable lint issues will never be auto-formatted.

Root Cause and Impact

The entry at .pre-commit-config.yaml:13 is:

entry: bash -c 'uv run ruff check --fix "$@" && uv run ruff format "$@"' --

ruff check --fix returns exit code 1 when violations remain after applying all available auto-fixes (e.g., rules that have no auto-fix available). The && operator short-circuits, so ruff format is never invoked.

Notably, the corresponding format-python-files Makefile target at Makefile:64-65 correctly uses ; (semicolons) to separate the commands, ensuring ruff format always runs regardless of ruff check --fix's exit code:

		uv run ruff check --fix $(FILES); \
		uv run ruff format $(FILES); \

Impact: When a developer commits Python files that have unfixable lint violations (which is common — many ruff rules are not auto-fixable), the formatting step is silently skipped. The developer's files won't be auto-formatted, defeating the purpose of the format hook.

Suggested change
entry: bash -c 'uv run ruff check --fix "$@" && uv run ruff format "$@"' --
entry: bash -c 'uv run ruff check --fix "$@"; uv run ruff format "$@"' --
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

pass_filenames: true

# File-aware lint hook - only runs on changed Python files
# Runs both ruff check and ruff format --check
- id: lint-files
name: Lint Changed Files
stages: [commit]
language: system
types: [python]
entry: uv run ruff check
entry: bash -c 'uv run ruff check "$@" && uv run ruff format --check "$@"' --
pass_filenames: true

# Conditional template hook - only runs when template files change
# Conditional template hook - only runs when template files or roadmap change
- id: template
name: Build Templates
stages: [commit]
language: system
files: ^infra/templates/|\.jinja2$
files: ^infra/templates/|\.jinja2$|^docs/roadmap\.md$
entry: make build-templates
pass_filenames: false