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

Function deserialize_type

mypyc/ir/rtypes.py:116–141  ·  view source on GitHub ↗

Deserialize a JSON-serialized RType. Arguments: data: The decoded JSON of the serialized type ctx: The deserialization maps to use

(data: JsonDict | str, ctx: DeserMaps)

Source from the content-addressed store, hash-verified

114
115
116def deserialize_type(data: JsonDict | str, ctx: DeserMaps) -> RType:
117 """Deserialize a JSON-serialized RType.
118
119 Arguments:
120 data: The decoded JSON of the serialized type
121 ctx: The deserialization maps to use
122 """
123 # Since there are so few types, we just case on them directly. If
124 # more get added we should switch to a system like mypy.types
125 # uses.
126 if isinstance(data, str):
127 if data in ctx.classes:
128 return RInstance(ctx.classes[data])
129 elif data in RPrimitive.primitive_map:
130 return RPrimitive.primitive_map[data]
131 elif data == "void":
132 return RVoid()
133 else:
134 assert False, f"Can't find class {data}"
135 elif data[".class"] == "RTuple":
136 return RTuple.deserialize(data, ctx)
137 elif data[".class"] == "RUnion":
138 return RUnion.deserialize(data, ctx)
139 elif data[".class"] == "RVec":
140 return RVec.deserialize(data, ctx)
141 raise NotImplementedError("unexpected .class {}".format(data[".class"]))
142
143
144class RTypeVisitor(Generic[T]):

Callers 7

deserializeMethod · 0.90
deserializeMethod · 0.90
deserializeMethod · 0.90
deserializeMethod · 0.90
deserializeMethod · 0.70
deserializeMethod · 0.70
deserializeMethod · 0.70

Calls 6

isinstanceFunction · 0.85
RInstanceClass · 0.85
RVoidClass · 0.85
NotImplementedErrorClass · 0.85
deserializeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…