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

Method deserialize

mypy/types.py:1706–1723  ·  view source on GitHub ↗
(cls, data: JsonDict | str)

Source from the content-addressed store, hash-verified

1704
1705 @classmethod
1706 def deserialize(cls, data: JsonDict | str) -> Instance:
1707 if isinstance(data, str):
1708 inst = Instance(NOT_READY, [])
1709 inst.type_ref = data
1710 return inst
1711 assert data[".class"] == "Instance"
1712 args: list[Type] = []
1713 if "args" in data:
1714 args_list = data["args"]
1715 assert isinstance(args_list, list)
1716 args = [deserialize_type(arg) for arg in args_list]
1717 inst = Instance(NOT_READY, args)
1718 inst.type_ref = data["type_ref"] # Will be fixed up by fixup.py later.
1719 if "last_known_value" in data:
1720 inst.last_known_value = LiteralType.deserialize(data["last_known_value"])
1721 if data.get("extra_attrs") is not None:
1722 inst.extra_attrs = ExtraAttrs.deserialize(data["extra_attrs"])
1723 return inst
1724
1725 def write(self, data: WriteBuffer) -> None:
1726 write_tag(data, INSTANCE)

Callers

nothing calls this directly

Calls 5

isinstanceFunction · 0.85
InstanceClass · 0.85
deserialize_typeFunction · 0.70
deserializeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected