Skip to content

Generic types that use ParamSpec aren't callable #11846

Closed
@NeilGirdhar

Description

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

from typing_extensions import ParamSpec

R = TypeVar('R')
P = ParamSpec('P')

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

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

partial(custom_vjp, x=0)  # error: Argument 1 to "partial" has incompatible type "Type[custom_vjp[Any, Any]]"; expected "Callable[..., custom_vjp[P, R]]"  [arg-type]

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