Closed
Description
from collections.abc import Callable
from functools import partial
from typing import Generic, TypeVar
from typing_extensions import ParamSpec
R_co = TypeVar('R_co', covariant=True)
P = ParamSpec('P')
class X(Generic[P, R_co]):
def __init__(self, f: Callable[P, R_co]):
super().__init__()
self.f = f
def __call__(self, /, *args: P.args, **kwargs: P.kwargs) -> R_co:
return self.f(*args, **kwargs)
@partial(X) # error: Argument 1 to "partial" has incompatible type "Type[X[Any, Any]]"; expected "Callable[..., X[P, R_co]]" [arg-type]
def f() -> int:
return 2
print(f())