Deterministic quality gate CLI for Python projects. Runs ruff + pyright + pytest, produces structured JSON artifacts, supports bounded auto-repair.
pip install -e ".[dev]"-- Installpytest-- 140 tests, all offlinepytest tests/test_run_command.py -v-- Single moduleruff check src/pygate/ --fix-- Lint fixpyright src/pygate/-- Type checkpython -m build-- Build
Three subcommands: pygate run (execute gates) → pygate repair (auto-fix loop) → pygate summarize (agent brief).
src/pygate/
cli.py → run_command.py / repair_command.py / summarize_command.py
gates/ruff.py, pyright.py, pytest_gate.py # Individual gates
models.py # Pydantic v2 models for all structured output
config.py # Config from pygate.toml or pyproject.toml
exec.py # Subprocess wrapper
deterministic_fix.py # ruff --fix with rollback safety
Key flow: run_command calls each gate → gate parses tool JSON output → results written as artifacts → exit code reflects pass/fail.
- Pydantic v2 for all models (not dataclasses)
from __future__ import annotationsin every module- JSON schemas in
schemas/must match Pydantic models - Tests never execute real subprocesses — all gate outputs mocked
- Repair loop is bounded by
--max-attempts(safety invariant) - Two runtime deps only:
pydantic,tomli(for Python <3.11)
- Package name on PyPI is
pygate-cibut import name ispygate hatchlingbuild system (not setuptools) — source lives insrc/pygate/pytest_gate.py(nottest_gate.py) to avoid pytest collecting it as a test- Config loading checks
pygate.tomlfirst, falls back to[tool.pygate]inpyproject.toml deterministic_fix.pycreates backup beforeruff --fixand rolls back on failure