From a91c0a1942c488f60f8f1504e70c39b64f2ffb07 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Thu, 15 Dec 2016 01:11:20 +0200 Subject: [PATCH] fix inference --- mypy/constraints.py | 2 ++ test-data/unit/check-classes.test | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/mypy/constraints.py b/mypy/constraints.py index 1d1e1c3328726..9a401729044a0 100644 --- a/mypy/constraints.py +++ b/mypy/constraints.py @@ -248,6 +248,8 @@ def visit_type_var(self, template: TypeVarType) -> List[Constraint]: def visit_instance(self, template: Instance) -> List[Constraint]: actual = self.actual res = [] # type: List[Constraint] + if isinstance(actual, CallableType) and actual.fallback is not None: + actual = actual.fallback if isinstance(actual, Instance): instance = actual if (self.direction == SUBTYPE_OF and diff --git a/test-data/unit/check-classes.test b/test-data/unit/check-classes.test index 266a0aae48ca3..7723e7755691b 100644 --- a/test-data/unit/check-classes.test +++ b/test-data/unit/check-classes.test @@ -2471,3 +2471,7 @@ class GoodMeta(type, Iterable[int]): class Good(metaclass=GoodMeta): pass for _ in Good: pass +reveal_type(list(Good)) # E: Revealed type is 'builtins.list[builtins.int*]' + +[builtins fixtures/list.pyi] +