From 5be0af87aea4ddc9a40fd1e2153375771b2ac794 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Tue, 7 Apr 2026 23:48:13 +0100 Subject: [PATCH] Fix exception handler target location in new parser --- mypy/nativeparse.py | 2 ++ pyproject.toml | 2 +- test-data/unit/check-statements.test | 4 +--- test-requirements.in | 2 +- test-requirements.txt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mypy/nativeparse.py b/mypy/nativeparse.py index 3ff184155bac2..c976ba9284401 100644 --- a/mypy/nativeparse.py +++ b/mypy/nativeparse.py @@ -280,6 +280,7 @@ def parse_to_binary_ast( platform=options.platform, always_true=options.always_true, always_false=options.always_false, + cache_version=1, ) return ( ast_bytes, @@ -823,6 +824,7 @@ def read_try_stmt(state: State, data: ReadBuffer) -> TryStmt: if has_name: var_name = read_str(data) var_expr = NameExpr(var_name) + read_loc(data, var_expr) vars_list.append(var_expr) else: vars_list.append(None) diff --git a/pyproject.toml b/pyproject.toml index 3f876316f0426..ac77889617cc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ python2 = [] reports = ["lxml"] install-types = ["pip"] faster-cache = ["orjson"] -native-parser = ["ast-serialize>=0.1.1,<1.0.0"] +native-parser = ["ast-serialize>=0.1.2,<1.0.0"] [project.urls] Homepage = "https://www.mypy-lang.org/" diff --git a/test-data/unit/check-statements.test b/test-data/unit/check-statements.test index 242a60be50ff2..b9ea7cdeae657 100644 --- a/test-data/unit/check-statements.test +++ b/test-data/unit/check-statements.test @@ -851,9 +851,7 @@ def error_in_tuple_union(exc: Tuple[Union[Type[E1], Type[E2]], Union[Type[E3], i pass [builtins fixtures/tuple.pyi] -[case testExceptWithMultipleTypes6_no_parallel] -# For no_parallel, see: -# https://github.com/mypyc/ast_serialize/issues/50 +[case testExceptWithMultipleTypes6] from typing import Never def random() -> bool: ... diff --git a/test-requirements.in b/test-requirements.in index d8227dcb89237..88d10f97f9c7a 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -13,4 +13,4 @@ pytest-cov>=2.10.0 setuptools>=77.0.3 tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.10 pre_commit>=3.5.0 -ast-serialize>=0.1.1,<1.0.0 +ast-serialize>=0.1.2,<1.0.0 diff --git a/test-requirements.txt b/test-requirements.txt index 5f8802825c59d..eac3524e5d7f7 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,7 +4,7 @@ # # pip-compile --allow-unsafe --output-file=test-requirements.txt --strip-extras test-requirements.in # -ast-serialize==0.1.1 +ast-serialize==0.1.2 # via -r test-requirements.in attrs==25.4.0 # via -r test-requirements.in