Skip to content

Commit d7fe756

Browse files
committed
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 4d64557 commit d7fe756

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: 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]:

Diff for: mypy/semanal.py

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

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

0 commit comments

Comments
 (0)