MCPcopy Index your code
hub / github.com/RustPython/RustPython / safe_parse_ast

Function safe_parse_ast

scripts/update_lib/file_utils.py:31–36  ·  view source on GitHub ↗

Parse Python content into AST, returning None on syntax error.

(content: str)

Source from the content-addressed store, hash-verified

29
30
31def safe_parse_ast(content: str) -> ast.Module | None:
32 """Parse Python content into AST, returning None on syntax error."""
33 try:
34 return ast.parse(content)
35 except SyntaxError:
36 return None
37
38
39def iter_python_files(path: pathlib.Path) -> Iterator[pathlib.Path]:

Callers 4

extract_test_methodsFunction · 0.90
parse_test_importsFunction · 0.90
parse_lib_importsFunction · 0.90

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected