MCPcopy
hub / github.com/python/mypy / write

Method write

mypy/types.py:1725–1751  ·  view source on GitHub ↗
(self, data: WriteBuffer)

Source from the content-addressed store, hash-verified

1723 return inst
1724
1725 def write(self, data: WriteBuffer) -> None:
1726 write_tag(data, INSTANCE)
1727 if not self.args and not self.last_known_value and not self.extra_attrs:
1728 type_ref = self.type.fullname
1729 if type_ref == "builtins.str":
1730 write_tag(data, INSTANCE_STR)
1731 elif type_ref == "builtins.function":
1732 write_tag(data, INSTANCE_FUNCTION)
1733 elif type_ref == "builtins.int":
1734 write_tag(data, INSTANCE_INT)
1735 elif type_ref == "builtins.bool":
1736 write_tag(data, INSTANCE_BOOL)
1737 elif type_ref == "builtins.object":
1738 write_tag(data, INSTANCE_OBJECT)
1739 else:
1740 write_tag(data, INSTANCE_SIMPLE)
1741 write_str_bare(data, type_ref)
1742 return
1743 write_tag(data, INSTANCE_GENERIC)
1744 write_str(data, self.type.fullname)
1745 write_type_list(data, self.args)
1746 write_type_opt(data, self.last_known_value)
1747 if self.extra_attrs is None:
1748 write_tag(data, LITERAL_NONE)
1749 else:
1750 self.extra_attrs.write(data)
1751 write_tag(data, END_TAG)
1752
1753 @classmethod
1754 def read(cls, data: ReadBuffer) -> Instance:

Callers

nothing calls this directly

Calls 4

write_strFunction · 0.90
write_type_listFunction · 0.85
write_type_optFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected