Skip to content

using a decorator on an overloaded function where the decorator uses Concatenate causes false positive "Overloaded function implementation does not accept all possible arguments" error #17459

Open
@DetachHead

Description

@DetachHead
from typing import Callable, Concatenate, TypeVar, overload, ParamSpec

T = TypeVar("T")
P = ParamSpec("P")
R = TypeVar("R")


def foo(fn: Callable[Concatenate[T, P], R]) -> Callable[Concatenate[T, P], R]:
    return fn


class Foo:
    @overload
    def bar(self, a: str) -> str: ...
    @overload
    def bar(self, a: int) -> int: ...

    # error: Overloaded function implementation does not accept all possible arguments of signature 1
    # error: Overloaded function implementation does not accept all possible arguments of signature 2
    @foo
    def bar(self, a: object) -> object: ...

playground

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