p2p-ld / numpydantic

Type annotations for specifying, validating, and serializing arrays with arbitrary backends in Pydantic (and beyond)
https://numpydantic.readthedocs.io/
MIT License
66 stars 1 forks source link

Subclasses not correctly re-cast after roundtrip json serialization #34

Open sneakers-the-rat opened 1 month ago

sneakers-the-rat commented 1 month ago

If a model annotation specifies some parent class, but a subclass is given to the model, when roundtripping the model to and from json, the data is cast back into the parent type since that's what's on the model. need an additional annotation in the dumped json to indicate the dtype class to cast back into. marking as an xfail in the tests for now

revealed in: https://github.com/p2p-ld/numpydantic/pull/31

want to merge that before trying to fix this.