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

Class CacheMetaEx

mypy/cache.py:244–295  ·  view source on GitHub ↗

Class representing "implementation-specific" part of cache metadata for a module.

Source from the content-addressed store, hash-verified

242
243
244class CacheMetaEx:
245 """Class representing "implementation-specific" part of cache metadata for a module."""
246
247 def __init__(
248 self,
249 dependencies: list[str],
250 suppressed: list[str],
251 dep_hashes: list[bytes],
252 error_lines: list[ErrorTuple],
253 ) -> None:
254 self.dependencies = dependencies
255 self.suppressed = suppressed
256 self.dep_hashes = dep_hashes
257 self.error_lines = error_lines
258
259 def serialize(self) -> dict[str, Any]:
260 return {
261 "dependencies": self.dependencies,
262 "suppressed": self.suppressed,
263 "dep_hashes": [dep.hex() for dep in self.dep_hashes],
264 "error_lines": self.error_lines,
265 }
266
267 @classmethod
268 def deserialize(cls, meta: dict[str, Any]) -> CacheMetaEx | None:
269 try:
270 return CacheMetaEx(
271 dependencies=meta["dependencies"],
272 suppressed=meta["suppressed"],
273 dep_hashes=[bytes.fromhex(dep) for dep in meta["dep_hashes"]],
274 error_lines=[tuple(err) for err in meta["error_lines"]],
275 )
276 except (KeyError, ValueError):
277 return None
278
279 def write(self, data: WriteBuffer) -> None:
280 write_str_list(data, self.dependencies)
281 write_str_list(data, self.suppressed)
282 write_bytes_list(data, self.dep_hashes)
283 write_errors(data, self.error_lines)
284
285 @classmethod
286 def read(cls, data: ReadBuffer) -> CacheMetaEx | None:
287 try:
288 return CacheMetaEx(
289 dependencies=read_str_list(data),
290 suppressed=read_str_list(data),
291 dep_hashes=read_bytes_list(data),
292 error_lines=read_errors(data),
293 )
294 except (ValueError, AssertionError):
295 return None
296
297
298# Always use this type alias to refer to type tags.

Callers 5

find_cache_metaFunction · 0.90
process_stale_sccFunction · 0.90
deserializeMethod · 0.85
readMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…