Small typing improvement here. @d-v-b - can you expand on what needs to be done (feel free to edit this description)?
edit from @d-v-b :
the v3 branch has models of zarr v3 metadata that do runtime validation of user input; e.g., array metadata is modeled with this class. Because the metadata models inherit from the base Metadata class, they can serialize to dictionaries. Right now, these output dictionaries are not typed, but we do know their types exactly.
So we should define TypedDict classes for every metadata model that has a well-defined dict representation (all of them, I think). I would also explore making the base Metadata class generic, with a type parameter bounded by dict[str, JSON], and using that type parameter for the return type of to_dict, and the input of from_dict.
These TypedDict instances will make the developer experience better, because we will know exactly what shape our dict-serialized metadata objects have.
Small typing improvement here. @d-v-b - can you expand on what needs to be done (feel free to edit this description)?
edit from @d-v-b :
the v3 branch has models of zarr v3 metadata that do runtime validation of user input; e.g., array metadata is modeled with this class. Because the metadata models inherit from the base Metadata class, they can serialize to dictionaries. Right now, these output dictionaries are not typed, but we do know their types exactly.
So we should define
TypedDict
classes for every metadata model that has a well-defined dict representation (all of them, I think). I would also explore making the base Metadata class generic, with a type parameter bounded bydict[str, JSON]
, and using that type parameter for the return type ofto_dict
, and the input offrom_dict
.These
TypedDict
instances will make the developer experience better, because we will know exactly what shape our dict-serialized metadata objects have.