Skip to content

Commit 70611e0

Browse files
author
Guido van Rossum
committed
Only delete cache errors in dependencies -- take two
Fixes #4135
1 parent 5830cd6 commit 70611e0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mypy/build.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,9 @@ class State:
14741474
# Whether to ignore all errors
14751475
ignore_all = False
14761476

1477+
# Whether the module has an error or any of its dependencies have one.
1478+
transitive_error = False
1479+
14771480
# Type checker used for checking this file. Use type_checker() for
14781481
# access and to construct this on demand.
14791482
_type_checker = None # type: Optional[TypeChecker]
@@ -1944,7 +1947,7 @@ def write_cache(self) -> None:
19441947
if self.manager.options.quick_and_dirty:
19451948
is_errors = self.manager.errors.is_errors_for_file(self.path)
19461949
else:
1947-
is_errors = self.manager.errors.is_errors()
1950+
is_errors = self.transitive_error
19481951
if is_errors:
19491952
delete_cache(self.id, self.path, self.manager)
19501953
self.meta = None
@@ -2257,6 +2260,10 @@ def process_graph(graph: Graph, manager: BuildManager) -> None:
22572260
else:
22582261
fresh_msg = "stale due to deps (%s)" % " ".join(sorted(stale_deps))
22592262

2263+
if any(graph[dep].transitive_error for dep in deps if dep in graph):
2264+
for id in scc:
2265+
graph[id].transitive_error = True
2266+
22602267
scc_str = " ".join(scc)
22612268
if fresh:
22622269
if not maybe_reuse_in_memory_tree(graph, scc, manager):
@@ -2464,6 +2471,9 @@ def process_stale_scc(graph: Graph, scc: List[str], manager: BuildManager) -> No
24642471
for id in stale:
24652472
if graph[id].type_check_second_pass():
24662473
more = True
2474+
if any(manager.errors.is_errors_for_file(graph[id].path) for id in stale):
2475+
for id in stale:
2476+
graph[id].transitive_error = True
24672477
for id in stale:
24682478
graph[id].finish_passes()
24692479
graph[id].write_cache()

0 commit comments

Comments
 (0)