[issue37485] dataclass __foo__ methods inheritance is not working
Colin
report at bugs.python.org
Tue Jul 2 09:44:03 EDT 2019
New submission from Colin <colin.bounouar at gmail.com>:
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 <report at bugs.python.org>
<https://bugs.python.org/issue37485>
_______________________________________
More information about the Python-bugs-list
mailing list