diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index da0edff7240c..2a62483e0b89 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -253,8 +253,7 @@ def check_fine_grained(self, sources: List[mypy.build.BuildSource]) -> Dict[str, def initialize_fine_grained(self, sources: List[mypy.build.BuildSource]) -> Dict[str, Any]: # The file system cache we create gets passed off to # BuildManager, and thence to FineGrainedBuildManager, which - # assumes responsibility for clearing it at the appropriate - # times (after init and update()). + # assumes responsibility for clearing it after updates. fscache = FileSystemCache(self.options.python_version) self.fswatcher = FileSystemWatcher(fscache) self.update_sources(sources) @@ -295,6 +294,7 @@ def initialize_fine_grained(self, sources: List[mypy.build.BuildSource]) -> Dict # Run an update messages = self.fine_grained_manager.update(self.find_changed(sources)) + fscache.flush() status = 1 if messages else 0 return {'out': ''.join(s + '\n' for s in messages), 'err': '', 'status': status} diff --git a/mypy/server/update.py b/mypy/server/update.py index 6c80cb9ee838..4bf625ed3774 100644 --- a/mypy/server/update.py +++ b/mypy/server/update.py @@ -175,7 +175,6 @@ def __init__(self, result: BuildResult) -> None: manager.saved_cache = {} # Active triggers during the last update self.triggered = [] # type: List[str] - self.manager.fscache.flush() def update(self, changed_modules: List[Tuple[str, str]]) -> List[str]: """Update previous build result by processing changed modules. diff --git a/mypy/test/testfinegrained.py b/mypy/test/testfinegrained.py index 83512cf0837f..7ffc3bef159c 100644 --- a/mypy/test/testfinegrained.py +++ b/mypy/test/testfinegrained.py @@ -86,6 +86,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None: fine_grained_manager = None if not self.use_cache: + result.manager.fscache.flush() fine_grained_manager = FineGrainedBuildManager(result) if CHECK_CONSISTENCY: check_consistency(fine_grained_manager) diff --git a/mypy/test/testmerge.py b/mypy/test/testmerge.py index 50d9d97a8a76..18fc51d8cbb3 100644 --- a/mypy/test/testmerge.py +++ b/mypy/test/testmerge.py @@ -69,6 +69,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None: main_src = '\n'.join(testcase.input) result = self.build(main_src) assert result is not None, 'cases where CompileError occurred should not be run' + result.manager.fscache.flush() fine_grained_manager = FineGrainedBuildManager(result) a = []