<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 29, 2017 at 11:37 AM, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 12/29/2017 02:23 AM, Ethan Smith wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The first is that needing both a keyword and method is duplicative and unnecessary. Eric agreed it was a hassle, but<br>
felt it was justified considering someone may accidentally override a dataclass method. I disagree with this point of<br>
view as dataclasses are billed as providing automatic methods. Overriding via method definition is very natural and<br>
idiomatic. I don't really see how someone could accidentally override a dataclass method if methods were not generated<br>
by the dataclass decorator that are already defined in the class at definition time.<br>
</blockquote>
<br></span>
Accidental or not, the decorator should not be replacing methods defined by the class.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The second concern, which I came across more recently, is if I have a base class, and dataclasses inherit from this base<br>
class, inherited __repr__ & co are silently overridden by dataclass. This is both unexpected, and also means I need to<br>
pass a repr=False to each subclass' decorator to get correct behavior, which somewhat defeats the utility of<br>
subclassing. Im not as sure a whole lot can be done about this though.<br>
</blockquote>
<br></span>
It is possible to determine whether an existing __repr__ is from 'object' or not, and only provide one if that is the case.  I think that should be the default, with 'repr = True' for those cases where a new, auto-generated, __repr__ is desired.<br></blockquote><div><br></div><div>The only other thing you'd want to handle is to cover inheriting from another dataclass. e.g., if I have dataclass with attribute a, and subclass it to add attribute b, I'd want both in the repr.</div><div><br></div><div>~>Ethan Smith<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--<br>
~Ethan~<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/ethan%40ethanhs.me" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/ethan%<wbr>40ethanhs.me</a><br>
</div></div></blockquote></div><br></div></div>