38 lines
1.3 KiB
Python
Executable File
38 lines
1.3 KiB
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)
|
|
|
|
# Check for cloud API calls
|
|
CLOUD_API_KEYWORDS = {
|
|
"openai", "anthropic", "openrouter", "nous", "kimi",
|
|
"api.openai.com", "api.anthropic.com", "openrouter.ai",
|
|
"api.nousresearch.com", "api.kimi.ai"
|
|
}
|
|
try:
|
|
with open(p, "r", encoding="utf-8") as f:
|
|
content = f.read().lower()
|
|
for keyword in CLOUD_API_KEYWORDS:
|
|
if keyword in content:
|
|
errors.append(f"{p}: Cloud API call detected: {keyword}")
|
|
print(f"CLOUD API CALL: {p}: {keyword}", file=sys.stderr)
|
|
break
|
|
except Exception as e:
|
|
print(f"ERROR reading {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")
|