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

Method read

mypy/types.py:1754–1800  ·  view source on GitHub ↗
(cls, data: ReadBuffer)

Source from the content-addressed store, hash-verified

1752
1753 @classmethod
1754 def read(cls, data: ReadBuffer) -> Instance:
1755 tag = read_tag(data)
1756 # This is quite verbose, but this is very hot code, so we are not
1757 # using dictionary lookups here.
1758 if tag == INSTANCE_STR:
1759 if instance_cache.str_type is None:
1760 instance_cache.str_type = Instance(NOT_READY, [])
1761 instance_cache.str_type.type_ref = "builtins.str"
1762 return instance_cache.str_type
1763 if tag == INSTANCE_FUNCTION:
1764 if instance_cache.function_type is None:
1765 instance_cache.function_type = Instance(NOT_READY, [])
1766 instance_cache.function_type.type_ref = "builtins.function"
1767 return instance_cache.function_type
1768 if tag == INSTANCE_INT:
1769 if instance_cache.int_type is None:
1770 instance_cache.int_type = Instance(NOT_READY, [])
1771 instance_cache.int_type.type_ref = "builtins.int"
1772 return instance_cache.int_type
1773 if tag == INSTANCE_BOOL:
1774 if instance_cache.bool_type is None:
1775 instance_cache.bool_type = Instance(NOT_READY, [])
1776 instance_cache.bool_type.type_ref = "builtins.bool"
1777 return instance_cache.bool_type
1778 if tag == INSTANCE_OBJECT:
1779 if instance_cache.object_type is None:
1780 instance_cache.object_type = Instance(NOT_READY, [])
1781 instance_cache.object_type.type_ref = "builtins.object"
1782 return instance_cache.object_type
1783 if tag == INSTANCE_SIMPLE:
1784 inst = Instance(NOT_READY, [])
1785 inst.type_ref = read_str_bare(data)
1786 return inst
1787 assert tag == INSTANCE_GENERIC
1788 type_ref = read_str(data)
1789 inst = Instance(NOT_READY, read_type_list(data))
1790 inst.type_ref = type_ref
1791 tag = read_tag(data)
1792 if tag != LITERAL_NONE:
1793 assert tag == LITERAL_TYPE
1794 inst.last_known_value = LiteralType.read(data)
1795 tag = read_tag(data)
1796 if tag != LITERAL_NONE:
1797 assert tag == EXTRA_ATTRS
1798 inst.extra_attrs = ExtraAttrs.read(data)
1799 assert read_tag(data) == END_TAG
1800 return inst
1801
1802 def copy_modified(
1803 self,

Callers

nothing calls this directly

Calls 4

read_strFunction · 0.90
InstanceClass · 0.85
read_type_listFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected