Files
hermes-agent/scripts/syntax_guard.py
Timmy Time a37fed23e6
Some checks failed
Forge CI / smoke-and-build (push) Failing after 2s
[BEZALEL][CI] Syntax Guard — Prevent Broken Python from Reaching Main (#167)
2026-04-07 02:27:32 +00:00

21 lines
624 B
Python
Executable File

#!/usr/bin/env python3
"""Syntax guard — compile all Python files to catch syntax errors before merge."""
import py_compile
import sys
from pathlib import Path
errors = []
for p in Path(".").rglob("*.py"):
if ".venv" in p.parts or "__pycache__" in p.parts:
continue
try:
py_compile.compile(str(p), doraise=True)
except py_compile.PyCompileError as e:
errors.append(f"{p}: {e}")
print(f"SYNTAX ERROR: {p}: {e}", file=sys.stderr)
if errors:
print(f"\n{len(errors)} file(s) with syntax errors", file=sys.stderr)
sys.exit(1)
print("All Python files compile successfully")