Skip to content

Commit 93ad7ce

Browse files
authored
Merge branch 'master' into parallel-native-parse
2 parents 24aad4f + bb05513 commit 93ad7ce

7 files changed

Lines changed: 16 additions & 20 deletions

File tree

mypy/build.py

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

881-
self.metastore = create_metastore(options, parallel_worker)
881+
self.metastore = create_metastore(options)
882882

883883
# a mapping from source files to their corresponding shadow files
884884
# for efficient lookup
@@ -1674,13 +1674,10 @@ def exclude_from_backups(target_dir: str) -> None:
16741674
pass
16751675

16761676

1677-
def create_metastore(options: Options, parallel_worker: bool = False) -> MetadataStore:
1677+
def create_metastore(options: Options) -> MetadataStore:
16781678
"""Create the appropriate metadata store."""
16791679
if options.sqlite_cache:
1680-
# We use this flag in both coordinator and workers to speed up commits,
1681-
# see mypy.metastore.connect_db() for details.
1682-
sync_off = options.num_workers > 0 or parallel_worker
1683-
mds: MetadataStore = SqliteMetadataStore(_cache_dir_prefix(options), sync_off=sync_off)
1680+
mds: MetadataStore = SqliteMetadataStore(_cache_dir_prefix(options))
16841681
else:
16851682
mds = FilesystemMetadataStore(_cache_dir_prefix(options))
16861683
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, check_same_thread=False)
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
@@ -285,6 +285,7 @@ def parse_to_binary_ast(
285285
platform=options.platform,
286286
always_true=options.always_true,
287287
always_false=options.always_false,
288+
cache_version=1,
288289
)
289290
return (
290291
ast_bytes,
@@ -828,6 +829,7 @@ def read_try_stmt(state: State, data: ReadBuffer) -> TryStmt:
828829
if has_name:
829830
var_name = read_str(data)
830831
var_expr = NameExpr(var_name)
832+
read_loc(data, var_expr)
831833
vars_list.append(var_expr)
832834
else:
833835
vars_list.append(None)

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)