(
filename: str, options: Options, skip_function_bodies: bool = False
)
| 248 | |
| 249 | |
| 250 | def parse_to_binary_ast( |
| 251 | filename: str, options: Options, skip_function_bodies: bool = False |
| 252 | ) -> tuple[bytes, list[ParseError], TypeIgnores, bytes, bool, bool, str, list[tuple[int, str]]]: |
| 253 | # This is a horrible hack to work around a mypyc bug where imported |
| 254 | # module may be not ready in a thread sometimes. |
| 255 | t0 = time.time() |
| 256 | while ast_serialize is None: |
| 257 | time.sleep(0.0001) # type: ignore[unreachable] |
| 258 | if time.time() - t0 > 10.0: |
| 259 | raise ImportError("Cannot import ast_serialize") |
| 260 | ast_bytes, errors, ignores, import_bytes, ast_data = ast_serialize.parse( |
| 261 | filename, |
| 262 | skip_function_bodies=skip_function_bodies, |
| 263 | python_version=options.python_version, |
| 264 | platform=options.platform, |
| 265 | always_true=options.always_true, |
| 266 | always_false=options.always_false, |
| 267 | cache_version=3, |
| 268 | ) |
| 269 | return ( |
| 270 | ast_bytes, |
| 271 | errors, |
| 272 | ignores, |
| 273 | import_bytes, |
| 274 | ast_data["is_partial_package"], |
| 275 | ast_data["uses_template_strings"], |
| 276 | ast_data["source_hash"], |
| 277 | ast_data["mypy_comments"], |
| 278 | ) |
| 279 | |
| 280 | |
| 281 | def read_statement(state: State, data: ReadBuffer) -> Statement: |
searching dependent graphs…