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

Method deserialize

mypy/nodes.py:4216–4279  ·  view source on GitHub ↗
(cls, data: JsonDict)

Source from the content-addressed store, hash-verified

4214
4215 @classmethod
4216 def deserialize(cls, data: JsonDict) -> TypeInfo:
4217 names = SymbolTable.deserialize(data["names"])
4218 defn = ClassDef.deserialize(data["defn"])
4219 module_name = data["module_name"]
4220 ti = TypeInfo(names, defn, module_name)
4221 ti._fullname = data["fullname"]
4222 ti.abstract_attributes = [(attr[0], attr[1]) for attr in data["abstract_attributes"]]
4223 ti.type_vars = data["type_vars"]
4224 ti.has_param_spec_type = data["has_param_spec_type"]
4225 ti.bases = [mypy.types.Instance.deserialize(b) for b in data["bases"]]
4226 _promote = []
4227 for p in data["_promote"]:
4228 t = mypy.types.deserialize_type(p)
4229 assert isinstance(t, mypy.types.ProperType)
4230 _promote.append(t)
4231 ti._promote = _promote
4232 ti.alt_promote = (
4233 None
4234 if data["alt_promote"] is None
4235 else mypy.types.Instance.deserialize(data["alt_promote"])
4236 )
4237 ti.declared_metaclass = (
4238 None
4239 if data["declared_metaclass"] is None
4240 else mypy.types.Instance.deserialize(data["declared_metaclass"])
4241 )
4242 ti.metaclass_type = (
4243 None
4244 if data["metaclass_type"] is None
4245 else mypy.types.Instance.deserialize(data["metaclass_type"])
4246 )
4247 # NOTE: ti.mro will be set in the fixup phase based on these
4248 # names. The reason we need to store the mro instead of just
4249 # recomputing it from base classes has to do with a subtle
4250 # point about fine-grained incremental: the cache files might
4251 # not be loaded until after a class in the mro has changed its
4252 # bases, which causes the mro to change. If we recomputed our
4253 # mro, we would compute the *new* mro, which leaves us with no
4254 # way to detect that the mro has changed! Thus we need to make
4255 # sure to load the original mro so that once the class is
4256 # rechecked, it can tell that the mro has changed.
4257 ti._mro_refs = data["mro"]
4258 ti.tuple_type = (
4259 None
4260 if data["tuple_type"] is None
4261 else mypy.types.TupleType.deserialize(data["tuple_type"])
4262 )
4263 ti.typeddict_type = (
4264 None
4265 if data["typeddict_type"] is None
4266 else mypy.types.TypedDictType.deserialize(data["typeddict_type"])
4267 )
4268 ti.metadata = data["metadata"]
4269 ti.slots = set(data["slots"]) if data["slots"] is not None else None
4270 ti.deletable_attributes = data["deletable_attributes"]
4271 set_flags(ti, data["flags"])
4272 st = data["self_type"]
4273 ti.self_type = mypy.types.TypeVarType.deserialize(st) if st is not None else None

Callers

nothing calls this directly

Calls 7

TypeInfoClass · 0.85
isinstanceFunction · 0.85
setClass · 0.85
set_flagsFunction · 0.85
appendMethod · 0.80
deserializeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected