[issue46739] dataclasses __eq__ isn't logical

2022-02-14 Thread Craig Coleman
Craig Coleman added the comment: >From https://docs.python.org/3/reference/datamodel.html#object.__hash__ User-defined classes have __eq__() and __hash__() methods by default; with them, all objects compare unequal (except with themselves) and x.__hash__() returns an appropriate value such

[issue46739] dataclasses __eq__ isn't logical

2022-02-14 Thread Craig Coleman
Craig Coleman added the comment: Seems I learned a python lesson today. I've put myself back in python school and done some reading on a) the code behind dataclasses, b) PEP 557 and c) the doc'n for __eq__. After all the reading I've realised this I'd been making some assumptions about how

[issue46739] dataclasses __eq__ isn't logical

2022-02-14 Thread Dennis Sweeney
Change by Dennis Sweeney : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue46739] dataclasses __eq__ isn't logical

2022-02-13 Thread Eric V. Smith
Change by Eric V. Smith : -- assignee: -> eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46739] dataclasses __eq__ isn't logical

2022-02-13 Thread Eric V. Smith
Eric V. Smith added the comment: I agree with Mark. It's identical to: >>> () == () True As for the non-dataclass version, that's a normal object identity comparison if no __eq__ is defined: https://docs.python.org/3/reference/datamodel.html#object.__eq__ , third paragraph. --

[issue46739] dataclasses __eq__ isn't logical

2022-02-13 Thread Mark Dickinson
Mark Dickinson added the comment: Can you explain why you think the result of `a == b` should be `False` rather than `True`? By default, equality for dataclasses is structural equality, and `True` is the result that I'd expect here. >From the

[issue46739] dataclasses __eq__ isn't logical

2022-02-13 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46739] dataclasses __eq__ isn't logical

2022-02-13 Thread Craig Coleman
New submission from Craig Coleman : 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