Closed
Description
To Reproduce
from typing import Protocol, ParamSpec, Callable, Concatenate
P = ParamSpec('P')
class FuncType(Protocol[P]):
def __call__(self, x: int, s: str,
*args: P.args, **kw_args: P.kwargs) -> str: ...
def forwarder1(fp: FuncType[P], *args: P.args, **kw_args: P.kwargs) -> str:
return fp(0, '', *args, **kw_args)
def forwarder2(fp: Callable[Concatenate[int, str, P], str],
*args: P.args, **kw_args: P.kwargs) -> str:
return fp(0, '', *args, **kw_args)
def my_f(x: int, s: str, d: float) -> str:
return f"{x}, {s}, {d}"
# error: Argument 1 to "forwarder1" has incompatible type "Callable[[int, str, float], str]";
# expected "FuncType[<nothing>]" [arg-type]
# error: Argument 2 to "forwarder1" has incompatible type "float";
# expected <nothing> [arg-type]
forwarder1(my_f, 1.2)
forwarder2(my_f, 1.2)
Expected Behavior
No error found.
Actual Behavior
Argument 1 to "forwarder1" has incompatible type "Callable[[int, str, float], str]"; expected "FuncType[]" [arg-type]
Argument 2 to "forwarder1" has incompatible type "float"; expected [arg-type]