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
Open
Nobody has claimed this yet.
bug
topic-paramspec
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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: ...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided reproducer in the mypy playground and inspect how overloaded implementations are checked when the implementation is decorated with a Callable using Concatenate. Confirm the false-positive errors for both overloads, then verify that valid decorated overloads pass without weakening the existing argument-compatibility checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100