(🐞) some dunder members (`__lt__`) on `dataclass`es show signatures inconsistently in error messages
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
from dataclasses import dataclass
from typing import Protocol
class Proto(Protocol):
def __lt__(self, other: object) -> None: ...
@dataclass(order=True)
class A:
pass
a: Proto = A()
mypy output
main.py:13: error: Incompatible types in assignment (expression has type "A", variable has type "Proto") [assignment]
main.py:13: note: Following member(s) of "A" have conflicts:
main.py:13: note: Expected:
main.py:13: note: def __lt__(self, object, /) -> None
main.py:13: note: Got:
main.py:13: note: def __lt__(other: A) -> bool
The signature of A's __lt__ is missing the self
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 by running the provided dataclass and Protocol example with mypy to reproduce the diagnostic. Trace how generated lt signatures are represented and rendered in the incompatibility note; done when the generated member signature reports self consistently with the expected signature.
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
- 35/100