erroneous complaint that overloaded function implementation does not accept all possible arguments of signature
Open
Nobody has claimed this yet.
bug
false-positive
topic-overloads
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Erroneous complaint that overloaded function implementation does not accept all possible arguments of signature.
To Reproduce
from datetime import datetime
from typing import overload
class Sample:
@overload
@classmethod
def set(cls, year: int) -> None:
...
@overload
@classmethod
def set(cls, instance: datetime, / ) -> None:
...
@classmethod
def set(cls, *args: datetime | int, **kw: int) -> None:
pass
Expected Behavior
The above should pass type checking.
Pyright's happy enough:
$ pyright typing_bug.py
0 errors, 0 warnings, 0 informations
Actual Behavior
$ mypy typing_bug.py
typing_bug.py:16: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used:
1.14.1 (compiled: yes) - Mypy command-line flags: None, see above
- Mypy configuration options from
mypy.ini(and other config files): None. - Python version used: Python 3.12.1
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
Reproduce the report from typing_bug.py with mypy 1.14.1 and compare the result with pyright. Trace the overload implementation compatibility check for the classmethod example; done means mypy accepts the shown code without the erroneous complaint while preserving valid diagnostics for incompatible implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100