diff --git a/mypy/plugin.py b/mypy/plugin.py index 3772d7039b05..201ec65748b9 100644 --- a/mypy/plugin.py +++ b/mypy/plugin.py @@ -257,6 +257,12 @@ def named_type(self, fullname: str, """Construct an instance of a builtin type with given type arguments.""" raise NotImplementedError + @abstractmethod + def builtin_type(self, fully_qualified_name: str) -> Instance: + """Legacy function -- use named_type() instead.""" + # NOTE: Do not delete this since many plugins may still use it. + raise NotImplementedError + @abstractmethod def named_type_or_none(self, fullname: str, args: Optional[List[Type]] = None) -> Optional[Instance]: diff --git a/mypy/semanal.py b/mypy/semanal.py index aca1f545c472..764fb4c36394 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -4567,6 +4567,10 @@ def named_type_or_none(self, fullname: str, return Instance(node, args) return Instance(node, [AnyType(TypeOfAny.unannotated)] * len(node.defn.type_vars)) + def builtin_type(self, fully_qualified_name: str) -> Instance: + """Legacy function -- use named_type() instead.""" + return self.named_type(fully_qualified_name) + def lookup_current_scope(self, name: str) -> Optional[SymbolTableNode]: if self.locals[-1] is not None: return self.locals[-1].get(name)