Skip to content

Commit cb7b9f1

Browse files
committed
Merge remote-tracking branch 'upstream/master' into revert-dict-or
2 parents 36c0e33 + 220424a commit cb7b9f1

8 files changed

Lines changed: 20 additions & 23 deletions

File tree

mypy/build.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ def __init__(
877877
]
878878
)
879879

880-
self.metastore = create_metastore(options, parallel_worker)
880+
self.metastore = create_metastore(options)
881881

882882
# a mapping from source files to their corresponding shadow files
883883
# for efficient lookup
@@ -1616,13 +1616,10 @@ def exclude_from_backups(target_dir: str) -> None:
16161616
pass
16171617

16181618

1619-
def create_metastore(options: Options, parallel_worker: bool = False) -> MetadataStore:
1619+
def create_metastore(options: Options) -> MetadataStore:
16201620
"""Create the appropriate metadata store."""
16211621
if options.sqlite_cache:
1622-
# We use this flag in both coordinator and workers to speed up commits,
1623-
# see mypy.metastore.connect_db() for details.
1624-
sync_off = options.num_workers > 0 or parallel_worker
1625-
mds: MetadataStore = SqliteMetadataStore(_cache_dir_prefix(options), sync_off=sync_off)
1622+
mds: MetadataStore = SqliteMetadataStore(_cache_dir_prefix(options))
16261623
else:
16271624
mds = FilesystemMetadataStore(_cache_dir_prefix(options))
16281625
return mds

mypy/metastore.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,20 @@ def close(self) -> None:
154154
"""
155155

156156

157-
def connect_db(db_file: str, sync_off: bool = False) -> sqlite3.Connection:
157+
def connect_db(db_file: str) -> sqlite3.Connection:
158158
import sqlite3.dbapi2
159159

160160
db = sqlite3.dbapi2.connect(db_file)
161-
if sync_off:
162-
# This is a bit unfortunate (as we may get corrupt cache after e.g. Ctrl + C),
163-
# but without this flag, commits are *very* slow, especially when using HDDs,
164-
# see https://www.sqlite.org/faq.html#q19 for details.
165-
db.execute("PRAGMA synchronous=OFF")
161+
# This is a bit unfortunate (as we may get corrupt cache after e.g. Ctrl + C),
162+
# but without this flag, commits are *very* slow, especially when using HDDs,
163+
# see https://www.sqlite.org/faq.html#q19 for details.
164+
db.execute("PRAGMA synchronous=OFF")
166165
db.executescript(SCHEMA)
167166
return db
168167

169168

170169
class SqliteMetadataStore(MetadataStore):
171-
def __init__(self, cache_dir_prefix: str, sync_off: bool = False) -> None:
170+
def __init__(self, cache_dir_prefix: str) -> None:
172171
# We check startswith instead of equality because the version
173172
# will have already been appended by the time the cache dir is
174173
# passed here.
@@ -177,7 +176,7 @@ def __init__(self, cache_dir_prefix: str, sync_off: bool = False) -> None:
177176
return
178177

179178
os.makedirs(cache_dir_prefix, exist_ok=True)
180-
self.db = connect_db(os_path_join(cache_dir_prefix, "cache.db"), sync_off=sync_off)
179+
self.db = connect_db(os_path_join(cache_dir_prefix, "cache.db"))
181180

182181
def _query(self, name: str, field: str) -> Any:
183182
# Raises FileNotFound for consistency with the file system version

mypy/nativeparse.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def parse_to_binary_ast(
280280
platform=options.platform,
281281
always_true=options.always_true,
282282
always_false=options.always_false,
283+
cache_version=1,
283284
)
284285
return (
285286
ast_bytes,
@@ -823,6 +824,7 @@ def read_try_stmt(state: State, data: ReadBuffer) -> TryStmt:
823824
if has_name:
824825
var_name = read_str(data)
825826
var_expr = NameExpr(var_name)
827+
read_loc(data, var_expr)
826828
vars_list.append(var_expr)
827829
else:
828830
vars_list.append(None)

mypyc/test-data/run-base64.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ def test_decode_with_extra_data_after_padding() -> None:
146146
check_decode(b"====", encoded=True)
147147
check_decode(b"eA===", encoded=True)
148148
check_decode(b"eHk==", encoded=True)
149-
check_decode(b"eA==x", encoded=True)
150-
check_decode(b"eHk=x", encoded=True)
151-
check_decode(b"eA==abc=======efg", encoded=True)
149+
# TODO: behavior in these cases changed in Python 3.14.4, we should match that.
150+
# check_decode(b"eA==x", encoded=True)
151+
# check_decode(b"eHk=x", encoded=True)
152+
# check_decode(b"eA==abc=======efg", encoded=True)
152153

153154
def test_decode_wrappers() -> None:
154155
funcs: list[Any] = [b64decode, urlsafe_b64decode]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ python2 = []
6464
reports = ["lxml"]
6565
install-types = ["pip"]
6666
faster-cache = ["orjson"]
67-
native-parser = ["ast-serialize>=0.1.1,<1.0.0"]
67+
native-parser = ["ast-serialize>=0.1.2,<1.0.0"]
6868

6969
[project.urls]
7070
Homepage = "https://www.mypy-lang.org/"

test-data/unit/check-statements.test

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,7 @@ def error_in_tuple_union(exc: Tuple[Union[Type[E1], Type[E2]], Union[Type[E3], i
851851
pass
852852
[builtins fixtures/tuple.pyi]
853853

854-
[case testExceptWithMultipleTypes6_no_parallel]
855-
# For no_parallel, see:
856-
# https://github.com/mypyc/ast_serialize/issues/50
854+
[case testExceptWithMultipleTypes6]
857855
from typing import Never
858856

859857
def random() -> bool: ...

test-requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ pytest-cov>=2.10.0
1313
setuptools>=77.0.3
1414
tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.10
1515
pre_commit>=3.5.0
16-
ast-serialize>=0.1.1,<1.0.0
16+
ast-serialize>=0.1.2,<1.0.0

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# pip-compile --allow-unsafe --output-file=test-requirements.txt --strip-extras test-requirements.in
66
#
7-
ast-serialize==0.1.1
7+
ast-serialize==0.1.2
88
# via -r test-requirements.in
99
attrs==25.4.0
1010
# via -r test-requirements.in

0 commit comments

Comments
 (0)