gendesign/.pre-commit-config.yaml
bot-backend 9457274c92
All checks were successful
CI Trade-In / changes (pull_request) Successful in 7s
CI / changes (pull_request) Successful in 9s
CI Trade-In / browser-tests (pull_request) Has been skipped
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 3m8s
CI Trade-In / backend-tests (pull_request) Successful in 5m40s
CI / backend-tests (pull_request) Successful in 17m53s
chore(tooling): pre-commit, pyproject и uv.lock — один ruff 0.15.20 (#2864)
Почему: хук пинил ruff v0.7.4, CI и `uv run ruff format` брали ruff из
lock'ов (0.15.12 в backend/, 0.15.20 в tradein-mvp/). Разные версии
по-разному форматируют длинные assert-сообщения — хук переписывал
нетронутые строки и ронял коммит на каждом касании файла (сегодня трижды),
а следующий `ruff format` возвращал как было. Дрейф нигде не краснел:
`ruff format --check` намеренно не в CI.

Что: rev → v0.15.20 (тег есть), `ruff==0.15.20` в обоих pyproject (с `>=`
любой `uv lock --upgrade` снова уведёт lock от хука), `uv lock` — в
lock'ах поменялся только ruff. Гейт test_2864_ruff_version_alignment.py:
rev == версии в обоих lock'ах == пин в pyproject; на origin/main красный
по значению (v0.7.4 ≠ 0.15.12 ≠ 0.15.20). `ruff check` 0.15.20 зелёный
на обоих проектах.

Нормализация 160 файлов под 0.15.20 — отдельным PR (только формат).

Refs #2864
2026-08-21 15:25:50 +05:00

55 lines
2.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Local pre-commit hooks. Install once with:
# pip install pre-commit
# pre-commit install
#
# After install: every `git commit` runs these checks against staged files.
# Failures abort the commit.
repos:
# Generic hygiene
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: ^backend/alembic/script.py.mako$
- id: check-toml
- id: check-added-large-files
args: ["--maxkb=512"]
# #1966: the frozen backtest regression-gate fixture is gzipped prod
# inputs (~3 MB). It is re-extracted rarely (only when ground-truth
# refreshes), so it does not bloat history per estimator change — the
# per-change artifact is the 3 KB backtest_baseline.json.
exclude: ^tradein-mvp/backend/tests/fixtures/backtest_full_fixture\.json\.gz$
- id: check-merge-conflict
- id: detect-private-key
# Python — ruff (lint + format) on backend/ + tradein-mvp/backend/
# #2864: rev ОБЯЗАН совпадать с версией ruff в backend/uv.lock и tradein-mvp/uv.lock
# (гейт backend/tests/test_2864_ruff_version_alignment.py). Иначе хук и
# `uv run ruff format` форматируют по-разному и играют в пинг-понг на каждом коммите.
# Бампить втроём: rev здесь + `ruff==X` в обоих pyproject.toml + `uv lock` в backend/ и tradein-mvp/.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
hooks:
- id: ruff
args: [--fix]
files: ^(backend|tradein-mvp/backend)/
- id: ruff-format
files: ^(backend|tradein-mvp/backend)/
# Frontend — prettier on TS/TSX/JSON.
# additional_dependencies pins the EXACT prettier engine (3.9.0) so this hook
# and CI (`openapi-codegen-check` → ./node_modules/.bin/prettier, also 3.9.0
# via frontend/package.json) format byte-for-byte identically. Без явного pin
# mirrors-prettier@v4.0.0-alpha.8 тянет CLI-обёртку, а CI `npx prettier`
# плавает в latest → расхождение формата → codegen-gate RED. Меняешь версию
# здесь — синхронно меняй prettier в frontend/package.json + lockfile.
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
additional_dependencies: ["prettier@3.9.0"]
files: ^frontend/.*\.(ts|tsx|js|jsx|json|css|md)$
exclude: ^frontend/(node_modules|\.next|package-lock\.json)/