Skip to content

Commit

Permalink
handle dumb decorators better
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Nov 27, 2021
1 parent 085b88f commit 64db099
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mypy/checker.py
Expand Up @@ -511,10 +511,12 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None:
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)
if isinstance(inner_call, CallableType):
impl_type = cast(CallableType, 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):
Expand Down
9 changes: 9 additions & 0 deletions test-data/unit/check-overloading.test
Expand Up @@ -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]

0 comments on commit 64db099

Please sign in to comment.