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

Function decompress

misc/analyze_cache.py:121–147  ·  view source on GitHub ↗
(chunk: JsonDict)

Source from the content-addressed store, hash-verified

119
120
121def decompress(chunk: JsonDict) -> JsonDict:
122 cache: dict[int, JsonDict] = {}
123
124 def helper(chunk: JsonDict) -> JsonDict:
125 if not isinstance(chunk, dict):
126 return chunk # type: ignore[unreachable] #TODO: is this actually unreachable, or are our types wrong?
127 if ".id" in chunk:
128 return cache[chunk[".id"]]
129
130 counter = None
131 if ".cache_id" in chunk:
132 counter = chunk[".cache_id"]
133 del chunk[".cache_id"]
134
135 for name in sorted(chunk.keys()):
136 value = chunk[name]
137 if isinstance(value, list):
138 chunk[name] = [helper(child) for child in value]
139 elif isinstance(value, dict):
140 chunk[name] = helper(value)
141
142 if counter is not None:
143 cache[counter] = chunk
144
145 return chunk
146
147 return helper(chunk)
148
149
150def main() -> None:

Callers 1

mainFunction · 0.85

Calls 1

helperFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…