Skip to content

ParamSpec parameters don't match __init__ parameters of class  #12986

Closed
@NeilGirdhar

Description

@NeilGirdhar
from functools import partial
from typing import Callable, Generic, ParamSpec

P = ParamSpec('P')

class custom_vjp(Generic[P]):
    def __init__(self,
                 fun: Callable[P, None],
                 x: int = 0):
        super().__init__()
        self.fun = fun

    def __call__(self, *args: P.args, **kwargs: P.kwargs) -> None:
        return self.fun(*args, **kwargs)

@partial(custom_vjp, x=1)  # error: Argument 1 to "partial" has incompatible type "Type[custom_vjp[Any]]"; expected "Callable[..., custom_vjp[P]]"
def f() -> None:
    pass

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