-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
Feature
We sometimes show the signature of __call__
when a value with a callable type is incompatible with a callback protocol, but not always. At least when checking argument types, we don't show the signature of __call__
:
from collections.abc import Callable
from typing import Protocol
class C(Protocol):
def __call__(self, a: int, b: str, c: bytes = b'', /) -> None: ...
def foo(c: C) -> None: ...
f: Callable[[int, str, bytes], None]
c: C
# error: Incompatible types in assignment (expression has type "Callable[[int, str, bytes], None]", variable has type "C")
# note: "C.__call__" has type "Callable[[int, str, DefaultArg(bytes)], None]"
c = f
# error: Argument 1 to "foo" has incompatible type "Callable[[int, str, bytes], None]"; expected "C"
foo(f)
I'd expect mypy to generate the note for the foo(f)
line as well.
(Also, DefaultArg(bytes)
is awkward in the note, but that's a separate issue.)