Message316331
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. |
|
Date |
User |
Action |
Args |
2018-05-09 20:50:00 | Ricyteach | set | recipients:
+ Ricyteach, eric.smith |
2018-05-09 20:50:00 | Ricyteach | set | messageid: <1525899000.83.0.682650639539.issue33452@psf.upfronthosting.co.za> |
2018-05-09 20:50:00 | Ricyteach | link | issue33452 messages |
2018-05-09 20:50:00 | Ricyteach | create | |
|