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
6 changes: 4 additions & 2 deletions mypy/nativeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
)
from mypy.util import decode_python_encoding, hash_digest, unnamed_function

AST_SERIALIZE_CACHE_VERSION: Final = 7

TypeIgnores = list[tuple[int, list[str]]]

# There is no way to create reasonable fallbacks at this stage,
Expand Down Expand Up @@ -419,7 +421,7 @@ def parse_to_binary_ast(
platform=options.platform,
always_true=options.always_true,
always_false=options.always_false,
cache_version=7,
cache_version=AST_SERIALIZE_CACHE_VERSION,
)
except ValueError as exc:
if source is None:
Expand All @@ -436,7 +438,7 @@ def parse_to_binary_ast(
platform=options.platform,
always_true=options.always_true,
always_false=options.always_false,
cache_version=5,
cache_version=AST_SERIALIZE_CACHE_VERSION,
)
# Compute hash using original non-UTF-8 bytes, so that
# incremental mode works correctly.
Expand Down
7 changes: 7 additions & 0 deletions mypy/test/test_nativeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ def test_latin1(self) -> None:
with temp_source(source, encoding="latin1") as fnam:
parse_to_binary_ast(fnam, Options())

def test_latin1_function(self) -> None:
source = "# coding: latin1\nJérôme = False\ndef f(): pass"
with temp_source(source, encoding="latin1") as fnam:
b, _, _, _, _, _, _, _, _ = parse_to_binary_ast(fnam, Options())
data = ReadBuffer(b)
read_statements(State(Options()), data, read_int(data))

def test_latin1_broken(self) -> None:
source = "# coding: ascii\nJérôme = False"
with temp_source(source, encoding="latin1") as fnam:
Expand Down
Loading