From 333b0cfc66f1b6666763c34d1b0d245bbdd85417 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Thu, 10 Nov 2016 17:06:19 +0200 Subject: [PATCH] initialize is_classmethod_class and fix test --- mypy/types.py | 6 +++++- test-data/unit/check-classes.test | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mypy/types.py b/mypy/types.py index 34c1ff2eb5847..3d1397187b3ee 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -592,6 +592,7 @@ def __init__(self, self.is_ellipsis_args = is_ellipsis_args self.implicit = implicit self.special_sig = special_sig + self.is_classmethod_class = is_classmethod_class super().__init__(line, column) def copy_modified(self, @@ -636,7 +637,10 @@ def type_object(self) -> mypy.nodes.TypeInfo: ret = self.ret_type if isinstance(ret, TupleType): ret = ret.fallback - return cast(Instance, ret).type + if isinstance(ret, TypeVarType): + ret = ret.upper_bound + assert isinstance(ret, Instance) + return ret.type def accept(self, visitor: 'TypeVisitor[T]') -> T: return visitor.visit_callable_type(self) diff --git a/test-data/unit/check-classes.test b/test-data/unit/check-classes.test index e6f0979723729..c0f69a673bf48 100644 --- a/test-data/unit/check-classes.test +++ b/test-data/unit/check-classes.test @@ -814,7 +814,8 @@ import typing class C: @classmethod def foo(cls) -> None: - cls().bar() + c = None # type: C + c.bar() @abstractmethod def bar(self) -> None: pass