MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / check_syntax

Function check_syntax

core/linter.py:40–51  ·  view source on GitHub ↗

Check Python syntax using ast.parse. Returns a human-readable error string on failure, None if valid.

(content: str, filename: str = "<string>")

Source from the content-addressed store, hash-verified

38# ── Syntax check (free, no external tools) ────────────────────────────────────
39
40def check_syntax(content: str, filename: str = "<string>") -> Optional[str]:
41 """
42 Check Python syntax using ast.parse.
43 Returns a human-readable error string on failure, None if valid.
44 """
45 try:
46 ast.parse(content, filename=filename)
47 return None
48 except SyntaxError as e:
49 return f"SyntaxError at line {e.lineno}: {e.msg}"
50 except Exception as e:
51 return f"Parse error: {e}"
52
53
54# ── Output parsers ─────────────────────────────────────────────────────────────

Callers 4

tool_patch_fileFunction · 0.90
_safe_writeFunction · 0.90
run_linterFunction · 0.85
run_all_lintersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected