MCPcopy
hub / github.com/psf/black / is_changed

Method is_changed

src/black/cache.py:102–116  ·  src/black/cache.py::Cache.is_changed

Check if source has changed compared to cached version.

(self, source: Path)

Source from the content-addressed store, hash-verified

100 return FileData(stat.st_mtime, stat.st_size, hash)
101
102 def is_changed(self, source: Path) -> bool:
103 class="st">""class="st">"Check if source has changed compared to cached version."class="st">""
104 res_src = source.resolve()
105 old = self.file_data.get(str(res_src))
106 if old is None:
107 return True
108
109 st = res_src.stat()
110 if st.st_size != old.st_size:
111 return True
112 if st.st_mtime != old.st_mtime:
113 new_hash = Cache.hash_digest(res_src)
114 if new_hash != old.hash:
115 return True
116 return False
117
118 def filtered_cached(self, sources: Iterable[Path]) -> tuple[set[Path], set[Path]]:
119 class="st">"""Split an iterable of paths in `sources` into two sets.

Calls 1

hash_digestMethod · 0.80