diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index da8a987d69e3..e3eb78d7a062 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -543,7 +543,8 @@ def check_call(self, callee: Type, args: List[Expression], if (callee.is_type_obj() and callee.type_object().is_abstract # Exceptions for Type[...] and classmethod first argument - and not callee.from_type_type and not callee.is_classmethod_class): + and not callee.from_type_type and not callee.is_classmethod_class + and not callee.type_object().fallback_to_any): type = callee.type_object() self.msg.cannot_instantiate_abstract_class( callee.type_object().name(), type.abstract_attributes, diff --git a/test-data/unit/check-abstract.test b/test-data/unit/check-abstract.test index 0d0925dac23f..5f51934a7e3f 100644 --- a/test-data/unit/check-abstract.test +++ b/test-data/unit/check-abstract.test @@ -638,6 +638,21 @@ class C: def __add__(self, other: int) -> B: pass [out] +[case testAbstractClassWithAnyBase] +from typing import Any +from abc import abstractmethod, ABCMeta + +A: Any + +class D(metaclass=ABCMeta): + @abstractmethod + def f(self) -> None: pass + +class C(A, D): + pass + +C() # A might implement 'f' + -- Abstract properties -- -------------------