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

Function encode_for_diff

misc/diff-cache.py:143–151  ·  view source on GitHub ↗

Encode a cache entry value for inclusion in the JSON diff. Fixed format binary entries are base64-encoded, JSON entries are re-serialized as JSON strings.

(s: str, obj: object)

Source from the content-addressed store, hash-verified

141
142
143def encode_for_diff(s: str, obj: object) -> str:
144 """Encode a cache entry value for inclusion in the JSON diff.
145
146 Fixed format binary entries are base64-encoded, JSON entries are
147 re-serialized as JSON strings.
148 """
149 if isinstance(obj, bytes):
150 return base64.b64encode(obj).decode()
151 return json_dumps(obj).decode()
152
153
154def main() -> None:

Callers 1

mainFunction · 0.85

Calls 3

json_dumpsFunction · 0.90
isinstanceFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…