[Python-Dev] Concerns about method overriding and subclassing with dataclasses (original) (raw)

Guido van Rossum guido at python.org
Fri Jan 5 11:24:21 EST 2018


On Fri, Jan 5, 2018 at 5:08 AM, Eric V. Smith <eric at trueblade.com> wrote:

On 1/2/2018 12:01 AM, Guido van Rossum wrote:

Yes, there's a class variable (dataclassfields) that identifies the parent fields. The PEP doesn't mention this or the fact that special methods (like repr and init) can tell whether a base class is a dataclass. It probably should though. (@Eric)

I think that's covered in this section: https://www.python.org/dev/pep s/pep-0557/#inheritance

I was specifically talking about the name and contents of dataclass_fields, which are not documented by the PEP. I expect it's inevitable that people will be looking at this (since they can see it in the source code). Or do you recommend that people use dataclasses.fields() and catch ValueError? I notice that _isdataclass() exists but is private and I don't recall why. (Also now I'm curious what the "pseudo-fields" are that fields() ignores, but that's OT.)

-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180105/92f515e0/attachment.html>



More information about the Python-Dev mailing list