You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our Metadata ABC defines to_dict and from_dict, and we use these methods to recursively read and write nested metadata documents to and from JSON. This would be fine if every implementation of Metadata serialized to a JSON object, but dtypes are a case where we have a rich in-memory representation that serializes to a simple string. data_type.to_dict() -> str is pretty confusing in this case, since one would expect to_dict to return a dict.
Since Metadata is a dataclass, someone who wants to recursively turn one into a dict can already use dataclasses.asdict. So maybe we should remove from_dict and to_dict, and instead define from_json and to_json, methods that turn a metadata model into a JSON-serializable form. This would make the job of these methods more obvious I think, and remove the confusing situation where to_dict doesn't produce a dict.
The text was updated successfully, but these errors were encountered:
Our
Metadata
ABC definesto_dict
andfrom_dict
, and we use these methods to recursively read and write nested metadata documents to and from JSON. This would be fine if every implementation ofMetadata
serialized to a JSON object, but dtypes are a case where we have a rich in-memory representation that serializes to a simple string.data_type.to_dict() -> str
is pretty confusing in this case, since one would expectto_dict
to return a dict.Since
Metadata
is a dataclass, someone who wants to recursively turn one into a dict can already usedataclasses.asdict
. So maybe we should removefrom_dict
andto_dict
, and instead definefrom_json
andto_json
, methods that turn a metadata model into a JSON-serializable form. This would make the job of these methods more obvious I think, and remove the confusing situation whereto_dict
doesn't produce a dict.The text was updated successfully, but these errors were encountered: