open-notebook/.pre-commit-config.yaml
Luis Novo e2a76dd6ca
Some checks are pending
Development Build / build-regular (push) Blocked by required conditions
Development Build / extract-version (push) Waiting to run
Development Build / changes (push) Waiting to run
Tests / Frontend Lint (push) Waiting to run
Tests / Frontend Build (push) Waiting to run
Tests / Backend Lint (push) Waiting to run
Tests / Backend Typecheck (push) Waiting to run
Development Build / build-single (push) Blocked by required conditions
Development Build / summary (push) Blocked by required conditions
Tests / Frontend Tests (push) Waiting to run
Tests / Backend Tests (push) Waiting to run
style: ruff format the Python codebase and gate it in CI (#1429)
* style: apply ruff format to the Python codebase

Formatting only, no behaviour change: `uv run ruff format .` with the repo's
existing ruff 0.14.13 config. One `# type: ignore[arg-type]` in
open_notebook/graphs/ask.py moves onto the argument line the formatter split
out, so mypy keeps applying it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GBYpxzSS62Y3TZkgB9NUZy

* ci: fail the Backend Lint job on unformatted Python

Adds `ruff format --check .` after `ruff check .`, matching the existing
ruff-format pre-commit hook, and updates the docs that said formatting was
not gated yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GBYpxzSS62Y3TZkgB9NUZy

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 07:12:25 -03:00

51 lines
2.4 KiB
YAML

# Pre-commit hooks mirroring the CI gates so local commits fail for the same
# reasons PRs would. See .github/workflows/test.yml for the CI equivalents.
#
# Install: uv run pre-commit install
# Run on all files: uv run pre-commit run --all-files
# Update hook versions: uv run pre-commit autoupdate
repos:
# ── Basic hygiene ──────────────────────────────────────────────────
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files # blocks >500 KB binaries
- id: check-merge-conflict # catches unresolved conflict markers
- id: check-yaml # validates YAML syntax
- id: check-toml # validates TOML syntax
- id: end-of-file-fixer # ensures files end with a newline
- id: trailing-whitespace # removes stray trailing whitespace
args: [--markdown-linebreak-ext=md]
# ── Ruff: Python lint & format (mirrors CI backend-lint job) ──────
# Version kept in sync with pyproject.toml [dependency-groups] dev.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.13
hooks:
# `ruff check --fix` — applies safe auto-fixes (e.g. import sorting)
# and reports remaining violations. CI runs `ruff check .` without
# --fix; the local auto-fix saves iteration with no drift risk.
- id: ruff
args: [--fix]
# `ruff format` — reformats files to match ruff's formatter. CI runs
# `ruff format --check .` with the same tool config, so there is no drift.
- id: ruff-format
# ── Mypy: Python type check (mirrors CI backend-typecheck job) ────
# Uses language: system so mypy runs through `uv` in the project's own
# virtualenv (the same way CI and `make lint` run it). Pre-commit's
# isolated mirror-mypy would miss errors from missing project deps like
# langgraph and langchain — that breaks the "no drift" rule.
#
# Note: type-checking the full project on every commit is slower than
# the per-file hooks above. Skip it with `SKIP=mypy git commit`.
- repo: local
hooks:
- id: mypy
name: mypy
entry: uv run python -m mypy .
language: system
types: [python]
pass_filenames: false
verbose: true