-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
Example:
from typing import Callable, Union, Any, overload, Protocol
class DCall(Protocol):
def __call__(self, arg: Union[int, str]) -> None:
...
class D:
def __getattr__(self, attr: str) -> DCall:
# This method might contain something like during runtime:
# if attr == '__call__':
# return some_func
# assert False
...
def dec_d(f: Callable[..., Any]) -> D:
return D()
@overload
def f_d(arg: int) -> None: ...
@overload
def f_d(arg: str) -> None: ...
@dec_d
def f_d(arg: Union[int, str]) -> None: ...
Outputs:
out/ex.py:18: error: "D" not callable
This happens here:
Lines 510 to 520 in 4f59ca4
if inner_type is not None and not isinstance(inner_type, AnyType): | |
if isinstance(inner_type, CallableType): | |
impl_type = inner_type | |
elif isinstance(inner_type, Instance): | |
inner_call = get_proper_type( | |
find_member('__call__', inner_type, inner_type, is_operator=True) | |
) | |
if isinstance(inner_call, CallableType): | |
impl_type = inner_call | |
if impl_type is None: | |
self.msg.not_callable(inner_type, defn.impl) |
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong