You can use Python's built-in`datatypes` also if you don't want an external library.
`pydantic` is unfortunately janky. Version 1 made custom serialization extremely hard. Version 2 changed that, but was not only backward incompatible in a number of non-trivial ways, but reserves all members starting with `model_` for itself.
Unfortunately, "model" is one of the most popular terms in programming these days. Once the complaints came flooding in, they give you a way to suppress this error, but if you then accidentally collide with one of their named fields, havoc will ensue.
Also, Pydantic's 2.0 rollout was extremely hard on developers. There were gross issues so they quickly came out with 2.1, then 2.2, 2.3 and 2.4, but these versions were not intercompatible with each other. Yes, I was having to respond to and fix bugs in my code for that.
Worse yet, writing code that's compatible with Pydantic 1 and 2 is decidedly non-trivial, and there's little documentation on how to do it, they just want you to upgrade, but most people's dependencies are still on Pydantic 1 because of the issues above.
I used to recommend pydantic if you had simple serialization but now I won't until the whole pydantic 2 mess gets cleaned up.