INNER CODE UNIT · Python
check_python_syntax
zhinkgit/embeddedskills · .github/maintenance/repo_checks.py:80
def check_python_syntax(root: Path) -> list[str]:
errors: list[str] = []
for path in matching_files(root, "*.py"):
try:
ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
except (SyntaxError, UnicodeDecodeError) as exc:
errors.append(f"{path.relative_to(root)}: {exc}")
return errors
def check_json(root: Path) -> list[str]:
errors: list[str] = []
for path in matching_files(root, "*.json"):
try:
json.loads(path.read_text(encoding="utf-8"))
except (json.JSONDecodeError, UnicodeDecodeError) as exc:
errors.append(f"{path.relative_to(root)}: {exc}")
return errors