Files
hermes-agent/scripts/syntax_guard.py

27 lines
805 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 any(excl in p.parts for excl in [".venv", "__pycache__", ".git", "node_modules", "dist"]):
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 not errors:
print("✅ All Python files compile successfully")
sys.exit(0)
if not p:
print("⚠️ No Python files found. Is this a Python project?", file=sys.stderr)
sys.exit(2)
print(f"\n{len(errors)} file(s) with syntax errors", file=sys.stderr)
sys.exit(1)