This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients brandtbucher, eric.smith, freundTech, gvanrossum
Date 2021-04-09.23:55:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618012519.83.0.360100556398.issue43764@roundup.psfhosted.org>
In-reply-to
Content
> init=False is used to make sure there's no __init__ defined, because there's a difference between a class with an __init__ and one without. If there was a difference between __match_args__ being not present and __match_args__=(), then I'd support a matchargs=False argument.

Ah, I see now how this might possibly be useful.

If you want to inherit a parent's __match_args__ in a dataclass, it currently must be as spelled something like:

@dataclass
class Child(Parent):
    __match_args__ = Parent.__match_args__
    ...

It's even uglier when you're unsure if Parent defines __match_args__ at all, or if multiple-inheritance is involved:

@dataclass
class Child(Parent, Mixin):
    __match_args__ = ()
    ...

del Child.__match_args__

I'm not sure how likely it is that code out in the wild may need to look like this. As I understand it, though, the fact that dataclasses allow for "normal" inheritance is one of their big selling-points. So it could be a valid reason to include this option.

If it seems like the above code might become reasonably common, I agree that the proposed solution is much cleaner:

@dataclass(match_args=False)
class Child(Parent):
    ...
History
Date User Action Args
2021-04-09 23:55:19brandtbuchersetrecipients: + brandtbucher, gvanrossum, eric.smith, freundTech
2021-04-09 23:55:19brandtbuchersetmessageid: <1618012519.83.0.360100556398.issue43764@roundup.psfhosted.org>
2021-04-09 23:55:19brandtbucherlinkissue43764 messages
2021-04-09 23:55:19brandtbuchercreate