Closed as not planned
Closed as not planned
Description
PEP-612 explains how Concatenate
can be used to write a wrapper where the output function requires less arguments than the wrapped one.
The opposite, where the output function requires more arguments than the wrapped one, is not clarified by the PEP, nor in my opinion it should, as it seems to be fairly non-controversial.
These work fine with mypy 1.7.0:
from typing import Callable, ParamSpec, TypeVar
P = ParamSpec("P")
R = TypeVar("R")
def w1(f: Callable[P, R], *args: P.args, **kwargs: P.kwargs) -> R:
return f(*args, **kwargs)
def w2(f: Callable[P, R], extra_arg: int, *args: P.args, **kwargs: P.kwargs) -> R:
return f(*args, **kwargs)
This however doesn't:
def w3(f: Callable[P, R], *args: P.args, extra_arg: int, **kwargs: P.kwargs) -> R:
return f(*args, **kwargs)
error: ParamSpec must have "*args" typed as "P.args" and "**kwargs" typed as "P.kwargs" [valid-type]