Skip to content

Commit 10f6e4d

Browse files
authored
Restore removed builtin_type() api method (#11932)
It shouldn't be used for new code, but adding it back makes it unnecessary to update existing plugins that no longer worked with mypy 0.930. Related issue: dropbox/sqlalchemy-stubs#232
1 parent e40877d commit 10f6e4d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mypy/plugin.py

+6
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ def named_type(self, fullname: str,
257257
"""Construct an instance of a builtin type with given type arguments."""
258258
raise NotImplementedError
259259

260+
@abstractmethod
261+
def builtin_type(self, fully_qualified_name: str) -> Instance:
262+
"""Legacy function -- use named_type() instead."""
263+
# NOTE: Do not delete this since many plugins may still use it.
264+
raise NotImplementedError
265+
260266
@abstractmethod
261267
def named_type_or_none(self, fullname: str,
262268
args: Optional[List[Type]] = None) -> Optional[Instance]:

mypy/semanal.py

+4
Original file line numberDiff line numberDiff line change
@@ -4567,6 +4567,10 @@ def named_type_or_none(self, fullname: str,
45674567
return Instance(node, args)
45684568
return Instance(node, [AnyType(TypeOfAny.unannotated)] * len(node.defn.type_vars))
45694569

4570+
def builtin_type(self, fully_qualified_name: str) -> Instance:
4571+
"""Legacy function -- use named_type() instead."""
4572+
return self.named_type(fully_qualified_name)
4573+
45704574
def lookup_current_scope(self, name: str) -> Optional[SymbolTableNode]:
45714575
if self.locals[-1] is not None:
45724576
return self.locals[-1].get(name)

0 commit comments

Comments
 (0)