Skip to content

Generic class with ParamSpec isn't callable as far as partial is concerned #14802

Description

@NeilGirdhar
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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-paramspecPEP 612, ParamSpec, Concatenate

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions