-
Notifications
You must be signed in to change notification settings - Fork 270
Description
This is related to #147, but not quite since I want to go beyond validation and have read/write support for things like TOML, METADATA
, etc.
I see two potential API forms. One is a dataclass-like object that stores the data with some methods to help read/write to various formats. The other form is a dict with various functions to manage the reading/writing.
I actually think the dict approach might be the best and easiest to work with for two reasons. One, I don't see anything inherent in the potential design that will require OOP (i.e. method overriding to influence results). I have not thought of an API that would call other methods where overriding would be necessary.
Two, it makes representing the explicit lack of data versus what goes into dynamic
ala PEP 621 more obvious. If the lack of a key means "information is explicitly not provided", then that can be expressed in a dict. If we make the existence of a key with a None
value represent something that would go into dynamic
, then we don't have to maintain dynamic
details separately. Using a dataclass doesn't buy us anything over this as it makes representing no data a little trickier as we would have to add some way to delineate that (e.g. some other false value that isn't None
?). Best benefit to a dataclass I can think of is a property to dynamically calculate dynamic
(😁 ) which could also be done with a function.
There's also no loss in typing as a partial TypedDict
would work in this instance.
So for me, the simplicity of using a dict for storing data in the appropriate formats and using the lack of key to delineate purposefully missing data is the way to go.