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

Method named_type

mypy/checker.py:7744–7769  ·  view source on GitHub ↗

Return an instance type with given name and implicit Any type args. For example, named_type('builtins.object') produces the 'object' type.

(self, name: str)

Source from the content-addressed store, hash-verified

7742 self.msg.possible_missing_await(context, code)
7743
7744 def named_type(self, name: str) -> Instance:
7745 """Return an instance type with given name and implicit Any type args.
7746
7747 For example, named_type('builtins.object') produces the 'object' type.
7748 """
7749 if name == "builtins.str":
7750 if instance_cache.str_type is None:
7751 instance_cache.str_type = self._named_type(name)
7752 return instance_cache.str_type
7753 if name == "builtins.function":
7754 if instance_cache.function_type is None:
7755 instance_cache.function_type = self._named_type(name)
7756 return instance_cache.function_type
7757 if name == "builtins.int":
7758 if instance_cache.int_type is None:
7759 instance_cache.int_type = self._named_type(name)
7760 return instance_cache.int_type
7761 if name == "builtins.bool":
7762 if instance_cache.bool_type is None:
7763 instance_cache.bool_type = self._named_type(name)
7764 return instance_cache.bool_type
7765 if name == "builtins.object":
7766 if instance_cache.object_type is None:
7767 instance_cache.object_type = self._named_type(name)
7768 return instance_cache.object_type
7769 return self._named_type(name)
7770
7771 def _named_type(self, name: str) -> Instance:
7772 # Assume that the name refers to a type.

Callers 15

check_first_passMethod · 0.95
check_getattr_methodMethod · 0.95
check_setattr_methodMethod · 0.95
check_lvalueMethod · 0.95
type_check_raiseMethod · 0.95
wrap_exception_groupMethod · 0.95

Calls 1

_named_typeMethod · 0.95

Tested by

no test coverage detected