bitter-ability-32190
01/09/2023, 7:39 PMfrozen_after_init
in lieu of doing what the Python docs recommend in this case: using object.__setattr__
.
See Python docs
And FWIW I didn't see this discussed when frozen_after_init
was introduced: https://github.com/pantsbuild/pants/pull/8431
The motivation is lowering the entry bar for plugin authors: Just do as the Romans do...bitter-ability-32190
01/09/2023, 7:47 PMobject.__setattr__(self, "attrname", attrvalue)
instead of self.attrname = attrvalue
but thats the current artflat-zoo-31952
01/09/2023, 8:55 PMfrozen_after_init
really that much of an additional burden for learners of plugins? I feel like the bit about "throw out virtually anything you know in Python that does IO because you need to interact with a Pants Monad to do anything" is a much bigger hurdle.
If anything frozen_after_init
felt like a welcome convenience because if I'm being forced to use frozen dataclasses to represent all info, at I have this way out.flat-zoo-31952
01/09/2023, 9:00 PMfrozen_after_init
for are to do validation, coercion, or other conversion. Would have been nice to use attrs for this rather than dataclasses, but it's too late now, as that's a massive API change attrs and dataclassess can't subclass the other typebitter-ability-32190
01/09/2023, 9:03 PMbitter-ability-32190
01/09/2023, 9:03 PMflat-zoo-31952
01/09/2023, 9:08 PMattrs
in all my projects when I can.flat-zoo-31952
01/09/2023, 9:10 PMfrozen_after_init
is very useful and simple enough to grok in a minute or two, even if it is a parochialismbitter-ability-32190
01/09/2023, 9:35 PMflat-zoo-31952
01/09/2023, 11:12 PMbitter-ability-32190
01/09/2023, 11:24 PMflat-zoo-31952
01/09/2023, 11:54 PMbitter-ability-32190
01/09/2023, 11:58 PMbitter-ability-32190
01/10/2023, 1:54 AMbitter-ability-32190
01/10/2023, 1:54 AMhappy-kitchen-89482
01/10/2023, 2:19 AMhappy-kitchen-89482
01/10/2023, 2:20 AMhappy-kitchen-89482
01/10/2023, 2:22 AMhappy-kitchen-89482
01/10/2023, 2:22 AMbitter-ability-32190
01/10/2023, 2:43 AMwitty-crayon-22786
01/10/2023, 5:55 PMfrozen_after_init
, we used to use __new__
overrides to add constructor logic to namedtuples. i suppose that that isn’t possible with dataclasses, but it was reasonably nice