Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ def initialize_fine_grained(self, sources: List[mypy.build.BuildSource]) -> Dict
self.fscache = FileSystemCache(self.options.python_version)
self.fswatcher = FileSystemWatcher(self.fscache)
self.update_sources(sources)
# Stores the initial state of sources as a side effect.
self.fswatcher.find_changed()
if not self.options.use_fine_grained_cache:
# Stores the initial state of sources as a side effect.
self.fswatcher.find_changed()
try:
# TODO: alt_lib_path
result = mypy.build.build(sources=sources,
Expand Down Expand Up @@ -288,19 +289,26 @@ def initialize_fine_grained(self, sources: List[mypy.build.BuildSource]) -> Dict
changed = self.find_changed(sources)
if changed:
messages = self.fine_grained_manager.update(changed)
self.fscache.flush()

status = 1 if messages else 0
self.previous_messages = messages[:]
return {'out': ''.join(s + '\n' for s in messages), 'err': '', 'status': status}

def fine_grained_increment(self, sources: List[mypy.build.BuildSource]) -> Dict[str, Any]:
t0 = time.time()
self.update_sources(sources)
changed = self.find_changed(sources)
t1 = time.time()
if not changed:
# Nothing changed -- just produce the same result as before.
messages = self.previous_messages
else:
messages = self.fine_grained_manager.update(changed)
t2 = time.time()
self.fine_grained_manager.manager.log(
"fine-grained increment: find_changed: {:.3f}s, update: {:.3f}s".format(
t1 - t0, t2 - t1))
status = 1 if messages else 0
self.previous_messages = messages[:]
self.previous_sources = sources
Expand Down
2 changes: 1 addition & 1 deletion mypy/fswatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def find_changed(self) -> Set[str]:
# Only look for changes if size or mtime has changed as an
# optimization, since calculating md5 is expensive.
new_md5 = self.fs.md5(path)
self._update(path)
if st.st_size != old.st_size or new_md5 != old.md5:
# Changed file.
changed.add(path)
self._update(path)
return changed