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 Ricyteach
Recipients Ricyteach, eric.smith
Date 2018-05-09.20:50:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1525899000.83.0.682650639539.issue33452@psf.upfronthosting.co.za>
In-reply-to
Content
The dataclasses module is incredibly easy to use. This is a good thing. BUT one downside is it will definitely be utilized by people who don't have a thorough understanding of how it does what it does.

Even for me, despite having a very good understanding of how it works, after heavily using it on a project for about 3 weeks now I made a mistake like the one below:

class ImportantMixin:
    def __init__(self):
        super().__init__()
        important_task()

@dataclass
class NaiveDClass(ImportantMixin):
  data1 = int
  data2 = int

I then went on along my merry way. Obviously, ImportantMixin.__init__ never gets called and I didn't realize this until it was a bigger problem than it should have been (should have written better tests! but I digress).

It would seem like a good idea for the dataclasses module to let the user know they did this, probably via the warning system. Seems like it would be relatively easy to do: if there is an init method being create, just inspect the MRO for any previously defined init methods that weren't created by dataclasses.

Thanks.
History
Date User Action Args
2018-05-09 20:50:00Ricyteachsetrecipients: + Ricyteach, eric.smith
2018-05-09 20:50:00Ricyteachsetmessageid: <1525899000.83.0.682650639539.issue33452@psf.upfronthosting.co.za>
2018-05-09 20:50:00Ricyteachlinkissue33452 messages
2018-05-09 20:50:00Ricyteachcreate