You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to get ParamSpec working for async-lru, and currently testing out the new partial() support added last year, but it doesn't seem to work with our wrapper class.
To Reproduce
fromfunctoolsimportpartialfromtypingimportAny, Callable, Coroutine, Generic, ParamSpec, TypeVar_R=TypeVar("_R")
_P=ParamSpec("_P")
classWrapper(Generic[_P, _R]):
def__init__(self, fn: Callable[_P, Coroutine[Any, Any, _R]]) ->None:
self.fn=fnasyncdef__call__(self, *args: _P.args, **kwargs: _P.kwargs) ->_R:
returnawaitself.fn(*args, **kwargs)
asyncdefcoro(val: int) ->int:
returnvalasyncdeftest() ->None:
coro_wrapped=Wrapper(coro)
reveal_type(coro_wrapped) # Revealed type is "Wrapper[[val: builtins.int], builtins.int]"awaitcoro_wrapped(3, 2) # error: Too many arguments for "__call__" of "Wrapper" [call-arg]partial_wrapped=Wrapper(partial(coro, 2))
reveal_type(partial_wrapped) # Revealed type is "Wrapper[[*args: Any, **kwargs: Any], builtins.int]"awaitpartial_wrapped(4) # XXX: Should be an error here.
For the record, this is a manifestation of #3832 because inferring signatures does not call the functools plugin for the functools.partial.__call__ signature.
Activity
A5rocks commentedon Feb 3, 2025
For the record, this is a manifestation of #3832 because inferring signatures does not call the
functoolsplugin for thefunctools.partial.__call__signature.Dreamsorcerer commentedon Jul 14, 2025
That issue appears to be marked as fixed in 1.17 though, while this still one still happens.
A5rocks commentedon Jul 26, 2025
I thought it would but here's the comment about why it doesn't: #18943 (comment)