Skip to content

Commit 64db099

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

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

mypy/checker.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,12 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None:
511511
impl_type = inner_type
512512
elif isinstance(inner_type, Instance):
513513
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)
514+
if isinstance(inner_call, CallableType):
515+
impl_type = cast(CallableType, inner_call)
516516
else:
517517
assert False
518+
if impl_type is None:
519+
self.msg.not_callable(inner_type, defn.impl)
518520

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

test-data/unit/check-overloading.test

Lines changed: 9 additions & 0 deletions
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)