Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions mypy/nativeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ def native_parse(
node.path = filename
return node, [], []

b, errors, ignores, import_bytes = parse_to_binary_ast(filename, options, skip_function_bodies)
b, errors, ignores, import_bytes, is_partial_package = parse_to_binary_ast(
filename, options, skip_function_bodies
)
data = ReadBuffer(b)
n = read_int(data)
state = State(options)
Expand All @@ -310,6 +312,7 @@ def native_parse(

node = MypyFile(defs, imports)
node.path = filename
node.is_partial_stub_package = is_partial_package
# Merge deserialization errors with parsing errors
all_errors = errors + state.errors
return node, all_errors, ignores
Expand All @@ -329,11 +332,11 @@ def read_statements(state: State, data: ReadBuffer, n: int) -> list[Statement]:

def parse_to_binary_ast(
filename: str, options: Options, skip_function_bodies: bool = False
) -> tuple[bytes, list[dict[str, Any]], TypeIgnores, bytes]:
ast_bytes, errors, ignores, import_bytes = ast_serialize.parse(
) -> tuple[bytes, list[dict[str, Any]], TypeIgnores, bytes, bool]:
ast_bytes, errors, ignores, import_bytes, is_partial_package = ast_serialize.parse(
filename, skip_function_bodies, python_version=options.python_version
)
return ast_bytes, errors, ignores, import_bytes
return ast_bytes, errors, ignores, import_bytes, is_partial_package


def read_statement(state: State, data: ReadBuffer) -> Statement:
Expand Down
2 changes: 1 addition & 1 deletion mypy/test/test_nativeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def locs(start_line: int, start_column: int, end_line: int, end_column: int) ->
]

with temp_source("print('hello')") as fnam:
b, _, _, _ = parse_to_binary_ast(fnam, Options())
b, _, _, _, _ = parse_to_binary_ast(fnam, Options())
assert list(b) == (
[LITERAL_INT, 22, nodes.EXPR_STMT, nodes.CALL_EXPR]
+ [nodes.NAME_EXPR, LITERAL_STR]
Expand Down