New submission from Colin <[email protected]>:
Hi,
When using inheritance with dataclass, "standard" instance methods that are
provided with a default behavior thanks to dataclass are not overridable using
inheritance.
Please see the sample below (or the attached file):
import dataclasses
@dataclasses.dataclass
class A:
def __eq__(self, other):
return True
@dataclasses.dataclass
class B(A):
pass
print(A() == 1) # Returns True as expected
print(B() == 1) # Returns False instead of True as expected via inheritance
Thanks again
----------
components: Library (Lib)
files: inheritance_dataclass_issue.py
messages: 347142
nosy: colin-b
priority: normal
severity: normal
status: open
title: dataclass __foo__ methods inheritance is not working
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48453/inheritance_dataclass_issue.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37485>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com