chore: add pre-commit ruff hook with auto-fix
Some checks failed
CI / test-cli (push) Successful in 11s
CI / test-sqlmesh (push) Successful in 12s
CI / test-web (push) Failing after 14s
CI / tag (push) Has been skipped

- scripts/hooks/pre-commit: runs ruff --fix for root and web/ (matching CI)
  and re-stages any auto-fixed files so they land in the commit
- Makefile: add install-hooks target (run once after clone)
- pyproject.toml: exclude web/ from root ruff (web has its own config)
- Fix remaining import sort warnings caught by the new hook

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-28 10:19:29 +01:00
parent c5a218490e
commit 42c1309b20
9 changed files with 36 additions and 13 deletions

22
scripts/hooks/pre-commit Normal file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Pre-commit hook: ruff lint + auto-fix.
# Install: make install-hooks
set -euo pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
RUFF="$REPO_ROOT/.venv/bin/ruff"
if [[ ! -x "$RUFF" ]]; then
echo "pre-commit: ruff not found at $RUFF — run 'uv sync' first" >&2
exit 1
fi
echo "→ ruff check (root)"
"$RUFF" check --fix "$REPO_ROOT"
echo "→ ruff check (web/src web/tests)"
"$RUFF" check --fix "$REPO_ROOT/web/src" "$REPO_ROOT/web/tests" \
--config "$REPO_ROOT/web/pyproject.toml"
# Re-stage any files ruff fixed so they land in the commit.
git diff --name-only | xargs -r git add