Read file content with UTF-8 encoding, returning None on error.
(path: pathlib.Path)
| 21 | |
| 22 | |
| 23 | def 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 | |
| 31 | def safe_parse_ast(content: str) -> ast.Module | None: |
no test coverage detected