If you persist your pydantic models (db, cache, queues, config, ...), a schema change can quietly break deserialization.
To help with this, stable_pydantic:
- tests for backward compatibility (new client reads old data)
- is easy to run on CI (just normal tests)
- stores schemas as Python files (easy to review/diff)
- optionally, tests for forward compatibility (old client reads new data)
- optionally, version-tags the data and handles migrations transparently
To setup, just copy a couple of tests from the README.
You can also adopt it incrementally, starting from just committing a copy of the models in a single file for easy diffing.
It does not cover custom validation logic, only model structure and built-in validation.
Let me know if you end up trying it, and of course if you spot any issues!