From faf9acdaaed77f238005bda52a355991df8f63c0 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 4 May 2018 10:02:44 +0100 Subject: [PATCH 1/2] Fallback to full run if protocol deps are missing or invalid --- mypy/build.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mypy/build.py b/mypy/build.py index 16a726b1627fc..f663d683bcaef 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -1088,7 +1088,7 @@ def get_protocol_deps_cache_name(manager: BuildManager) -> Tuple[str, str]: contains hashes of all source files at the time the protocol dependencies were written, and data file contains the protocol dependencies. """ - name = os.path.join(_cache_dir_prefix(manager), 'proto_deps') + name = os.path.join(_cache_dir_prefix(manager), '@proto_deps') return name + '.meta.json', name + '.data.json' @@ -2342,11 +2342,15 @@ def dispatch(sources: List[BuildSource], manager: BuildManager) -> Graph: # after we loaded cache for whole graph. The `read_protocol_cache` will also validate # the protocol cache against the loaded individual cache files. TypeState.proto_deps = read_protocol_cache(manager, graph) - if TypeState.proto_deps is None and manager.stats.get('fresh_trees', 0) > 0: + if TypeState.proto_deps is None and manager.stats.get('fresh_metas', 0) > 0: # There were some cache files read, but no protocol dependencies loaded. - manager.errors.set_file(_cache_dir_prefix(manager), None) - manager.errors.report(0, 0, "Error reading protocol dependencies cache -- aborting", - blocker=True) + manager.log("Error reading protocol dependencies cache -- aborting cache load") + manager.cache_enabled = False + TypeState.proto_deps = {} + manager.log("Falling back to full run -- reloading graph...") + graph = load_graph(sources, manager) + process_graph(graph, manager) + else: process_graph(graph, manager) if manager.options.cache_fine_grained or manager.options.fine_grained_incremental: From d5e11a55a40d35b8caba3f5d0fe63056b0c1a6b1 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 4 May 2018 11:33:11 +0100 Subject: [PATCH 2/2] Call dispatch recursively instead of manually reloading graph --- mypy/build.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/build.py b/mypy/build.py index f663d683bcaef..f6fb27ae74b62 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -2348,8 +2348,7 @@ def dispatch(sources: List[BuildSource], manager: BuildManager) -> Graph: manager.cache_enabled = False TypeState.proto_deps = {} manager.log("Falling back to full run -- reloading graph...") - graph = load_graph(sources, manager) - process_graph(graph, manager) + return dispatch(sources, manager) else: process_graph(graph, manager)