python / python/mypy

Callable[..., T] causes false positive in overload checks

Open
#6,140 1 comment 0 reactions 1 assignee View on GitHub

@Michael0x2a is already working on this.

Since Jan 4, 2019.

bug false-positive priority-1-normal topic-overloads
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

This example:

@overload
def deco(f: Callable[[], int]) -> Callable[[], str]: ...
@overload
def deco(f: Callable[..., int]) -> Callable[..., str]: ...
def deco(f):
    pass

causes

Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader

But it should be allowed (the same way we allow various last overloads with Any types).

cc @Michael0x2a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.