Skip to content

Commit e600b0e

Browse files
author
hauntsaninja
committed
handle dumb decorators better
1 parent 085b88f commit e600b0e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

mypy/checker.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,15 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None:
510510
if isinstance(inner_type, CallableType):
511511
impl_type = inner_type
512512
elif isinstance(inner_type, Instance):
513-
inner_call = find_member('__call__', inner_type, inner_type, is_operator=True)
514-
assert inner_call is not None
515-
impl_type = cast(CallableType, inner_call)
513+
inner_call = get_proper_type(
514+
find_member('__call__', inner_type, inner_type, is_operator=True)
515+
)
516+
if isinstance(inner_call, CallableType):
517+
impl_type = inner_call
516518
else:
517519
assert False
520+
if impl_type is None:
521+
self.msg.not_callable(inner_type, defn.impl)
518522

519523
is_descriptor_get = defn.info and defn.name == "__get__"
520524
for i, item in enumerate(defn.items):

test-data/unit/check-overloading.test

+9
Original file line numberDiff line numberDiff line change
@@ -5382,4 +5382,13 @@ def f_c(arg: int) -> None: ...
53825382
def f_c(arg: str) -> None: ...
53835383
@dec_c # E: Overloaded function implementation does not accept all possible arguments of signature 2
53845384
def f_c(arg): ...
5385+
5386+
def dec_d(f: Callable[..., Any]) -> int: ...
5387+
5388+
@overload
5389+
def f_d(arg: int) -> None: ...
5390+
@overload
5391+
def f_d(arg: str) -> None: ...
5392+
@dec_d # E: "int" not callable
5393+
def f_d(arg): ...
53855394
[builtins fixtures/dict.pyi]

0 commit comments

Comments
 (0)