fromcollections.abcimportCallablefromfunctoolsimportpartialfromtypingimportGeneric, TypeVarfromtyping_extensionsimportParamSpecR_co=TypeVar('R_co', covariant=True)
P=ParamSpec('P')
classX(Generic[P, R_co]):
def__init__(self, f: Callable[P, R_co]):
super().__init__()
self.f=fdef__call__(self, /, *args: P.args, **kwargs: P.kwargs) ->R_co:
returnself.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]deff() ->int:
return2print(f())