New submission from Craig Coleman <[email protected]>:
In a test, dataclasses generate an __eq__ function appears to be wrong.
@dataclass
class C:
pass
class K:
pass
a = C()
b = C()
c = K()
d = K()
(a is b) # False
(a == b) # True # Incorrect, Why?
(c is d) # False
(c == d) # False # Correct
Using @dataclass(eq = False) for annotation of C would make (a == b) == False
which I think is correct behaviour.
----------
components: Library (Lib)
messages: 413188
nosy: ccoleman
priority: normal
severity: normal
status: open
title: dataclasses __eq__ isn't logical
type: behavior
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46739>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com