-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
This came up in python/typeshed#2379. Consider the following code:
from typing import Protocol
class Caller(Protocol):
def __call__(self) -> None: ...
def call() -> None:
pass
def func(caller: Caller) -> None:
pass
func(call)Currently, mypy 0.620 rejects this:
foo.py:12: error: Argument 1 to "func" has incompatible type "Callable[[], None]"; expected "Caller"
I believe that mypy should actually allow this, because call is actually an object that fulfills the protocol. This would also open up the opportunity to create callback signatures of any complexity (for example, default and keyword-only arguments) without the need for additional features for Callable.
devxpy and lukasjuhrich