bitter-ability-3219001/09/2023, 7:39 PM
in lieu of doing what the Python docs recommend in this case: using
See Python docs
And FWIW I didn't see this discussed when
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...
object.__setattr__(self, "attrname", attrvalue)
but thats the current art
self.attrname = attrvalue
flat-zoo-3195201/09/2023, 8:55 PM
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.
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.
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 type
bitter-ability-3219001/09/2023, 9:03 PM
flat-zoo-3195201/09/2023, 9:08 PM
in all my projects when I can.
is very useful and simple enough to grok in a minute or two, even if it is a parochialism
bitter-ability-3219001/09/2023, 9:35 PM
flat-zoo-3195201/09/2023, 11:12 PM
bitter-ability-3219001/09/2023, 11:24 PM
flat-zoo-3195201/09/2023, 11:54 PM
bitter-ability-3219001/09/2023, 11:58 PM
happy-kitchen-8948201/10/2023, 2:19 AM
bitter-ability-3219001/10/2023, 2:43 AM
witty-crayon-2278601/10/2023, 5:55 PM
, we used to use
overrides to add constructor logic to namedtuples. i suppose that that isn’t possible with dataclasses, but it was reasonably nice