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

Function safe_read_text

scripts/update_lib/file_utils.py:23–28  ·  view source on GitHub ↗

Read file content with UTF-8 encoding, returning None on error.

(path: pathlib.Path)

Source from the content-addressed store, hash-verified

21
22
23def safe_read_text(path: pathlib.Path) -> str | None:
24 """Read file content with UTF-8 encoding, returning None on error."""
25 try:
26 return path.read_text(encoding="utf-8")
27 except (OSError, UnicodeDecodeError):
28 return None
29
30
31def safe_parse_ast(content: str) -> ast.Module | None:

Callers 7

collect_original_methodsFunction · 0.90
count_todo_in_pathFunction · 0.90
_count_file_diffFunction · 0.90
_count_path_diffFunction · 0.90
_build_test_import_graphFunction · 0.90
_build_lib_import_graphFunction · 0.90
read_python_filesFunction · 0.85

Calls 1

read_textMethod · 0.45

Tested by

no test coverage detected