@@ -17,7 +17,6 @@ def parse(
1717 module : str | None ,
1818 errors : Errors ,
1919 options : Options ,
20- file_exists : bool ,
2120 eager : bool = False ,
2221) -> MypyFile :
2322 """Parse a source file, without doing any semantic analysis.
@@ -29,25 +28,21 @@ def parse(
2928 the parse errors, use eager=True.
3029 """
3130 if options .native_parser :
32- # Native parser only works with actual files on disk
33- # Fall back to fastparse for in-memory source or non-existent files
34- if file_exists :
35- import mypy .nativeparse
36-
37- ignore_errors = options .ignore_errors or fnam in errors .ignored_files
38- # If errors are ignored, we can drop many function bodies to speed up type checking.
39- strip_function_bodies = ignore_errors and not options .preserve_asts
40- tree , _ , _ = mypy .nativeparse .native_parse (
41- fnam , options , skip_function_bodies = strip_function_bodies
42- )
43- # Set is_stub based on file extension
44- tree .is_stub = fnam .endswith (".pyi" )
45- # Note: tree.imports is populated directly by load_from_raw() with deserialized
46- # import metadata, so we don't need to collect imports via AST traversal
47- if eager and tree .raw_data is not None :
48- tree = load_from_raw (fnam , module , tree .raw_data , errors , options )
49- return tree
50- # Fall through to fastparse for non-existent files
31+ import mypy .nativeparse
32+
33+ ignore_errors = options .ignore_errors or fnam in errors .ignored_files
34+ # If errors are ignored, we can drop many function bodies to speed up type checking.
35+ strip_function_bodies = ignore_errors and not options .preserve_asts
36+ tree , _ , _ = mypy .nativeparse .native_parse (
37+ fnam , options , source , skip_function_bodies = strip_function_bodies
38+ )
39+ # Set is_stub based on file extension
40+ tree .is_stub = fnam .endswith (".pyi" )
41+ # Note: tree.imports is populated directly by load_from_raw() with deserialized
42+ # import metadata, so we don't need to collect imports via AST traversal
43+ if eager and tree .raw_data is not None :
44+ tree = load_from_raw (fnam , module , tree .raw_data , errors , options )
45+ return tree
5146
5247 if options .transform_source is not None :
5348 source = options .transform_source (source )
0 commit comments