58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Test script to check for syntax errors"""
|
|
|
|
import sys
|
|
import py_compile
|
|
from pathlib import Path
|
|
|
|
def check_syntax(file_path):
|
|
"""Check Python file for syntax errors"""
|
|
try:
|
|
py_compile.compile(str(file_path), doraise=True)
|
|
print(f"✓ {file_path.name}: No syntax errors")
|
|
return True
|
|
except py_compile.PyCompileError as e:
|
|
print(f"✗ {file_path.name}: Syntax error!")
|
|
print(f" Line {e.exc_value.lineno}: {e.exc_value.msg}")
|
|
print(f" {e.exc_value.text}")
|
|
return False
|
|
|
|
def main():
|
|
"""Check all Python files for syntax errors"""
|
|
project_root = Path(__file__).parent
|
|
src_dir = project_root / "src"
|
|
|
|
python_files = [
|
|
src_dir / "connector" / "openai_client.py",
|
|
src_dir / "connector" / "config.py",
|
|
src_dir / "connector" / "__init__.py",
|
|
src_dir / "server" / "mcp_server.py",
|
|
src_dir / "server" / "handlers.py",
|
|
src_dir / "server" / "models.py",
|
|
src_dir / "utils" / "image_utils.py",
|
|
src_dir / "utils" / "token_utils.py",
|
|
project_root / "main.py"
|
|
]
|
|
|
|
print("Checking Python files for syntax errors...")
|
|
print("=" * 50)
|
|
|
|
errors_found = False
|
|
for file_path in python_files:
|
|
if file_path.exists():
|
|
if not check_syntax(file_path):
|
|
errors_found = True
|
|
else:
|
|
print(f"⚠ {file_path.name}: File not found")
|
|
|
|
print("=" * 50)
|
|
if errors_found:
|
|
print("❌ Syntax errors found!")
|
|
return 1
|
|
else:
|
|
print("✅ All files passed syntax check!")
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|