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

Method serialize

mypy/nodes.py:4176–4213  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4174 return mypy.strconv.dump_tagged(items, head, str_conv=str_conv)
4175
4176 def serialize(self) -> JsonDict:
4177 # NOTE: This is where all ClassDefs originate, so there shouldn't be duplicates.
4178 data = {
4179 ".class": "TypeInfo",
4180 "module_name": self.module_name,
4181 "fullname": self.fullname,
4182 "names": self.names.serialize(self.fullname),
4183 "defn": self.defn.serialize(),
4184 "abstract_attributes": self.abstract_attributes,
4185 "type_vars": self.type_vars,
4186 "has_param_spec_type": self.has_param_spec_type,
4187 "bases": [b.serialize() for b in self.bases],
4188 "mro": [c.fullname for c in self.mro],
4189 "_promote": [p.serialize() for p in self._promote],
4190 "alt_promote": None if self.alt_promote is None else self.alt_promote.serialize(),
4191 "declared_metaclass": (
4192 None if self.declared_metaclass is None else self.declared_metaclass.serialize()
4193 ),
4194 "metaclass_type": (
4195 None if self.metaclass_type is None else self.metaclass_type.serialize()
4196 ),
4197 "tuple_type": None if self.tuple_type is None else self.tuple_type.serialize(),
4198 "typeddict_type": (
4199 None if self.typeddict_type is None else self.typeddict_type.serialize()
4200 ),
4201 "flags": get_flags(self, TypeInfo.FLAGS),
4202 "metadata": self.metadata,
4203 "slots": sorted(self.slots) if self.slots is not None else None,
4204 "deletable_attributes": self.deletable_attributes,
4205 "self_type": self.self_type.serialize() if self.self_type is not None else None,
4206 "dataclass_transform_spec": (
4207 self.dataclass_transform_spec.serialize()
4208 if self.dataclass_transform_spec is not None
4209 else None
4210 ),
4211 "deprecated": self.deprecated,
4212 }
4213 return data
4214
4215 @classmethod
4216 def deserialize(cls, data: JsonDict) -> TypeInfo:

Callers

nothing calls this directly

Calls 3

get_flagsFunction · 0.85
sortedFunction · 0.85
serializeMethod · 0.45

Tested by

no test coverage detected