Open
Description
Bug Report
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
from typing import Any, Callable, Coroutine, Generic, ParamSpec, TypeVar
_R = TypeVar("_R")
_P = ParamSpec("_P")
class Wrapper(Generic[_P, _R]):
def __init__(self, fn: Callable[_P, Coroutine[Any, Any, _R]]) -> None:
self.fn = fn
async def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
return await self.fn(*args, **kwargs)
async def coro(val: int) -> int:
return val
async def test() -> None:
coro_wrapped = Wrapper(coro)
reveal_type(coro_wrapped) # Revealed type is "Wrapper[[val: builtins.int], builtins.int]"
await coro_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]"
await partial_wrapped(4) # XXX: Should be an error here.
Your Environment
- Mypy version used: 1.14.1
- Python version used: 3.9