From e600b0eca60591323d456a45bf1e513caeb79a73 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sat, 27 Nov 2021 01:37:50 -0800 Subject: [PATCH] handle dumb decorators better --- mypy/checker.py | 10 +++++++--- test-data/unit/check-overloading.test | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mypy/checker.py b/mypy/checker.py index c80eb8b9b83a..acc6abfa5fbc 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -510,11 +510,15 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None: if isinstance(inner_type, CallableType): impl_type = inner_type elif isinstance(inner_type, Instance): - inner_call = find_member('__call__', inner_type, inner_type, is_operator=True) - assert inner_call is not None - impl_type = cast(CallableType, inner_call) + inner_call = get_proper_type( + find_member('__call__', inner_type, inner_type, is_operator=True) + ) + if isinstance(inner_call, CallableType): + impl_type = inner_call else: assert False + if impl_type is None: + self.msg.not_callable(inner_type, defn.impl) is_descriptor_get = defn.info and defn.name == "__get__" for i, item in enumerate(defn.items): diff --git a/test-data/unit/check-overloading.test b/test-data/unit/check-overloading.test index 5f34cdd511c3..de7261e47492 100644 --- a/test-data/unit/check-overloading.test +++ b/test-data/unit/check-overloading.test @@ -5382,4 +5382,13 @@ def f_c(arg: int) -> None: ... def f_c(arg: str) -> None: ... @dec_c # E: Overloaded function implementation does not accept all possible arguments of signature 2 def f_c(arg): ... + +def dec_d(f: Callable[..., Any]) -> int: ... + +@overload +def f_d(arg: int) -> None: ... +@overload +def f_d(arg: str) -> None: ... +@dec_d # E: "int" not callable +def f_d(arg): ... [builtins fixtures/dict.pyi]