Add a serializer
Would be nice to have a serializer back to s-expressions from our types. I would propose a to_list
method in our base type and a top-level to_str
for everything to mirror from_str
. We'll have to see how much special case handling we have to do.
As a bonus we can then write property based tests using the Pydantic Hypothesis plugin that generates unlimited random test cases for our assertions given something like:
@given(st.builds(Schematic))
def test_retains_when_serialized(instance):
assert from_str(to_str(instance)) == instance
Edited by Kaspar Emanuel