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

Method visit_instance

mypy/types.py:3744–3766  ·  view source on GitHub ↗
(self, t: Instance, /)

Source from the content-addressed store, hash-verified

3742 return f"<Deleted '{t.source}'>"
3743
3744 def visit_instance(self, t: Instance, /) -> str:
3745 fullname = t.type.fullname
3746 if not self.options.reveal_verbose_types and fullname.startswith("builtins."):
3747 fullname = t.type.name
3748 if t.last_known_value and not t.args:
3749 # Instances with a literal fallback should never be generic. If they are,
3750 # something went wrong so we fall back to showing the full Instance repr.
3751 s = f"{t.last_known_value.accept(self)}?"
3752
3753 else:
3754 s = fullname or t.type.name or "<???>"
3755
3756 if t.args:
3757 if t.type.fullname == "builtins.tuple":
3758 assert len(t.args) == 1
3759 s += f"[{self.list_str(t.args)}, ...]"
3760 else:
3761 s += f"[{self.list_str(t.args)}]"
3762 elif t.type.has_type_var_tuple_type and len(t.type.type_vars) == 1:
3763 s += "[()]"
3764 if self.id_mapper:
3765 s += f"<{self.id_mapper.id(t.type)}>"
3766 return s
3767
3768 def visit_type_var(self, t: TypeVarType, /) -> str:
3769 if not self.options.reveal_verbose_types:

Callers 1

acceptMethod · 0.45

Calls 5

list_strMethod · 0.95
lenFunction · 0.85
startswithMethod · 0.45
acceptMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected