Incompatible signature using `singledispatchmethod` in a subclass
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Mypy can't handle singledispatchmethod overloading a method in a subclass
To Reproduce
from functools import singledispatchmethod
class A:
def foo(self, bar: object) -> object:
return True
class B(A):
@singledispatchmethod
def foo(self, bar: object) -> object:
return super().foo(bar)
@foo.register
def int_impl(self, bar: int) -> int:
return bar + 2
Expected Behavior
I wasn't expecting any error in this piece of code.
Actual Behavior
test.py:11: error: Signature of "foo" incompatible with supertype "A" [override]
Found 1 error in 1 file (checked 1 source file)
My Environment
- Mypy version used: 0.990
- Python version used: 3.11
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
The issue names no repository file or test; start by running the provided Python reproducer against mypy. Trace the incompatible-signature diagnostic around subclass overrides and singledispatchmethod handling, then add regression coverage and verify the example is accepted without errors.
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
- Clearly specified
- Newbie friendliness
- 38/100