Skip to content

Commit e1f1147

Browse files
Merge branch 'master' into str-lower-upper
2 parents bb9ba27 + f8f618a commit e1f1147

File tree

6 files changed

+376
-46
lines changed

6 files changed

+376
-46
lines changed

CHANGELOG.md

Lines changed: 316 additions & 0 deletions
Large diffs are not rendered by default.

mypy/build.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,34 +3303,7 @@ def process_graph(graph: Graph, manager: BuildManager) -> None:
33033303
if undeps:
33043304
fresh = False
33053305
if fresh:
3306-
# All cache files are fresh. Check that no dependency's
3307-
# cache file is newer than any scc node's cache file.
3308-
oldest_in_scc = min(graph[id].xmeta.data_mtime for id in scc)
3309-
viable = {id for id in stale_deps if graph[id].meta is not None}
3310-
newest_in_deps = (
3311-
0 if not viable else max(graph[dep].xmeta.data_mtime for dep in viable)
3312-
)
3313-
if manager.options.verbosity >= 3: # Dump all mtimes for extreme debugging.
3314-
all_ids = sorted(ascc | viable, key=lambda id: graph[id].xmeta.data_mtime)
3315-
for id in all_ids:
3316-
if id in scc:
3317-
if graph[id].xmeta.data_mtime < newest_in_deps:
3318-
key = "*id:"
3319-
else:
3320-
key = "id:"
3321-
else:
3322-
if graph[id].xmeta.data_mtime > oldest_in_scc:
3323-
key = "+dep:"
3324-
else:
3325-
key = "dep:"
3326-
manager.trace(" %5s %.0f %s" % (key, graph[id].xmeta.data_mtime, id))
3327-
# If equal, give the benefit of the doubt, due to 1-sec time granularity
3328-
# (on some platforms).
3329-
if oldest_in_scc < newest_in_deps:
3330-
fresh = False
3331-
fresh_msg = f"out of date by {newest_in_deps - oldest_in_scc:.0f} seconds"
3332-
else:
3333-
fresh_msg = "fresh"
3306+
fresh_msg = "fresh"
33343307
elif undeps:
33353308
fresh_msg = f"stale due to changed suppression ({' '.join(sorted(undeps))})"
33363309
elif stale_scc:

mypy/main.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,13 +1204,6 @@ def add_invertible_flag(
12041204
)
12051205

12061206
if server_options:
1207-
# TODO: This flag is superfluous; remove after a short transition (2018-03-16)
1208-
other_group.add_argument(
1209-
"--experimental",
1210-
action="store_true",
1211-
dest="fine_grained_incremental",
1212-
help="Enable fine-grained incremental mode",
1213-
)
12141207
other_group.add_argument(
12151208
"--use-fine-grained-cache",
12161209
action="store_true",

mypy/nodes.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4254,8 +4254,6 @@ def serialize(self) -> JsonDict:
42544254
"alias_tvars": [v.serialize() for v in self.alias_tvars],
42554255
"no_args": self.no_args,
42564256
"normalized": self.normalized,
4257-
"line": self.line,
4258-
"column": self.column,
42594257
"python_3_12_type_alias": self.python_3_12_type_alias,
42604258
}
42614259
return data
@@ -4270,15 +4268,13 @@ def deserialize(cls, data: JsonDict) -> TypeAlias:
42704268
target = mypy.types.deserialize_type(data["target"])
42714269
no_args = data["no_args"]
42724270
normalized = data["normalized"]
4273-
line = data["line"]
4274-
column = data["column"]
42754271
python_3_12_type_alias = data["python_3_12_type_alias"]
42764272
return cls(
42774273
target,
42784274
fullname,
42794275
module,
4280-
line,
4281-
column,
4276+
-1,
4277+
-1,
42824278
alias_tvars=cast(list[mypy.types.TypeVarLikeType], alias_tvars),
42834279
no_args=no_args,
42844280
normalized=normalized,
@@ -4291,8 +4287,6 @@ def write(self, data: Buffer) -> None:
42914287
write_str(data, self.module)
42924288
self.target.write(data)
42934289
mypy.types.write_type_list(data, self.alias_tvars)
4294-
write_int(data, self.line)
4295-
write_int(data, self.column)
42964290
write_bool(data, self.no_args)
42974291
write_bool(data, self.normalized)
42984292
write_bool(data, self.python_3_12_type_alias)
@@ -4307,8 +4301,8 @@ def read(cls, data: Buffer) -> TypeAlias:
43074301
target,
43084302
fullname,
43094303
module,
4310-
read_int(data),
4311-
read_int(data),
4304+
-1,
4305+
-1,
43124306
alias_tvars=alias_tvars,
43134307
no_args=read_bool(data),
43144308
normalized=read_bool(data),

mypyc/irbuild/prepare.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,13 @@ def load_type_map(mapper: Mapper, modules: list[MypyFile], deser_ctx: DeserMaps)
159159
"""Populate a Mapper with deserialized IR from a list of modules."""
160160
for module in modules:
161161
for node in module.names.values():
162-
if isinstance(node.node, TypeInfo) and is_from_module(node.node, module):
162+
if (
163+
isinstance(node.node, TypeInfo)
164+
and is_from_module(node.node, module)
165+
and not node.node.is_newtype
166+
and not node.node.is_named_tuple
167+
and node.node.typeddict_type is None
168+
):
163169
ir = deser_ctx.classes[node.node.fullname]
164170
mapper.type_to_ir[node.node] = ir
165171
mapper.symbol_fullnames.add(node.node.fullname)

mypyc/test-data/run-multimodule.test

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,3 +902,51 @@ import native
902902
[out2]
903903
0
904904
None
905+
906+
[case testIncrementalCompilationWithNonClassTypeDef]
907+
import other_a
908+
[file other_a.py]
909+
from other_b import MyInt
910+
[file other_a.py.2]
911+
from other_b import MyInt, NT, TD
912+
i = MyInt(42)
913+
914+
def f(x: MyInt) -> int:
915+
return x + 1
916+
917+
def g(x: int) -> MyInt:
918+
return MyInt(x + 2)
919+
920+
print(i)
921+
print(f(i))
922+
print(g(13))
923+
924+
def make_nt(x: int) -> NT:
925+
return NT(x=MyInt(x))
926+
927+
print(make_nt(4))
928+
929+
def make_td(x: int) -> TD:
930+
return {"x": MyInt(x)}
931+
932+
print(make_td(5))
933+
934+
[file other_b.py]
935+
from typing import NewType, NamedTuple, TypedDict
936+
from enum import Enum
937+
938+
MyInt = NewType("MyInt", int)
939+
NT = NamedTuple("NT", [("x", MyInt)])
940+
TD = TypedDict("TD", {"x": MyInt})
941+
942+
[file driver.py]
943+
import native
944+
945+
[typing fixtures/typing-full.pyi]
946+
[out]
947+
[out2]
948+
42
949+
43
950+
15
951+
NT(x=4)
952+
{'x': 5}

0 commit comments

Comments
 (0)