https://pantsbuild.org/ logo
#development
Title
# development
h

happy-kitchen-89482

08/09/2019, 5:34 PM
Random question: has there been any thought given to using standard Python3.7 dataclasses and type annotations instead of our custom
datatype
? Would that be hard to do?
a

aloof-angle-91616

08/09/2019, 5:34 PM
yes!
we should do it and it is planned! let me find the ticket
w

witty-crayon-22786

08/09/2019, 5:35 PM
i think that we might still end up with some customizations to avoid mutability and prevent overriding
eq
, but using it as an implementation detail might work.
a

aloof-angle-91616

08/09/2019, 5:36 PM
i was trying to start moving towards that when i made
DatatypeMixin
and
ChoicesMixin
, to decouple the extended functionality we're looking for from the specific backend implementation
h

happy-kitchen-89482

08/09/2019, 5:37 PM
You can mark dataclasses as
frozen=True
šŸ‘ 1
Which emulates immutability to a good enough degree
šŸ‘ 1
w

witty-crayon-22786

08/09/2019, 6:34 PM
how do you enforce that they are marked? and/or make that the default.
(anywho: it feels to me like swapping from extending
namedtuple
to extending "dataclass")
h

hundreds-father-404

08/09/2019, 6:45 PM
Yes Iā€™m hoping to see this. For enforcing that people make it frozen, I think code review should catch most cases
w

witty-crayon-22786

08/09/2019, 6:46 PM
Well, that's why superclass. To avoid allowing them to do the wrong
h

hundreds-father-404

08/09/2019, 6:46 PM
We can superclass dataclass then. Sgtm
h

happy-kitchen-89482

08/09/2019, 6:48 PM
Presumably you can check that they're marked when validating the product graph
extending
dataclass
is less of a win IMO, because now the code needs to import from Pants again
šŸ‘ 1
a

aloof-angle-91616

08/09/2019, 6:48 PM
not necessarily
or at least, pants will accept exactly one type, be it a
datatype
or
dataclass
. the surrounding python code should only need a two-way adapter to its own objects
w

witty-crayon-22786

08/09/2019, 7:00 PM
And there is nothing enforcing use of datatype with the engine (...yet?). From a sandbox perspective that may eventually be a thing, but it isn't now
a

aloof-angle-91616

08/09/2019, 7:00 PM
retweet