Skip to content

(fn: Callable[P, ...]) -> ... is considered fully overlapped by (fn: Callable[[], ...]) -> ... #10587

@InSyncWithFoo

Description

@InSyncWithFoo

Consider the following example (playground):

class ParamSpecBoundAtDecoratorCallSite(Protocol):
    def __call__[**P, T](self, fn: Callable[P, T], /) -> Callable[P, T]: ...

class ParamSpecBoundAtFactoryCallSite[**P](Protocol):
    def __call__[T](self, fn: Callable[P, T], /) -> Callable[P, T]: ...

@overload
def f(fn: Callable[[], Any]) -> ParamSpecBoundAtDecoratorCallSite: ...
@overload
def f[**P](fn: Callable[P, Any]) -> ParamSpecBoundAtFactoryCallSite[P]: ...
# error: Overload 2 for "f" will never be used because its parameters overlap overload 1

def f(fn: ...) -> ...: ...

This is wrong: The second overload will be reached for all fn which expect at least one argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions