MCPcopy Index your code
hub / github.com/python/mypy / _find_changed

Method _find_changed

mypy/fswatcher.py:65–89  ·  view source on GitHub ↗
(self, paths: Iterable[str])

Source from the content-addressed store, hash-verified

63 self._file_data[path] = FileData(st.st_mtime, st.st_size, hash_digest)
64
65 def _find_changed(self, paths: Iterable[str]) -> AbstractSet[str]:
66 changed = set()
67 for path in paths:
68 old = self._file_data[path]
69 st = self.fs.stat_or_none(path)
70 if st is None:
71 if old is not None:
72 # File was deleted.
73 changed.add(path)
74 self._file_data[path] = None
75 else:
76 if old is None:
77 # File is new.
78 changed.add(path)
79 self._update(path, st)
80 # Round mtimes down, to match the mtimes we write to meta files
81 elif st.st_size != old.st_size or int(st.st_mtime) != int(old.st_mtime):
82 # Only look for changes if size or mtime has changed as an
83 # optimization, since calculating hash is expensive.
84 new_hash = self.fs.hash_digest(path)
85 self._update(path, st)
86 if st.st_size != old.st_size or new_hash != old.hash:
87 # Changed file.
88 changed.add(path)
89 return changed
90
91 def find_changed(self) -> AbstractSet[str]:
92 """Return paths that have changes since the last call, in the watched set."""

Callers 2

find_changedMethod · 0.95
update_changedMethod · 0.95

Calls 6

_updateMethod · 0.95
setClass · 0.85
intClass · 0.85
stat_or_noneMethod · 0.80
hash_digestMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected