by nitred · 4y ago · 0 comments
It has excellent support for JSON and JSON schemas out of the box.
Error messages are excellent! Tells you exactly what went wrong (most of the time) during validation.
I do use Pydantic even when Dataclass and NamedTuples are sufficient, I know that's a bit cargo cultish but it lowers the mental overhead by just having to perfect one of way of doing things.
That's exactly the point. The mental burden of remembering the quirks of (and having to choose between) namedtuples, typeddicts, dataclasses etc is very real.
The Pydantic page itself provides some pretty nice notes on why it's awesome: https://pydantic-docs.helpmanual.io/#rationale
Coercion is quite powerful and saves me quite a bit of work. I write validation for config files that non programmers create. I would happily avoid explaining the difference between a 1 and a "1" to them whenever I can and let coercion do the work. It reduces the mental load on them too.
https://pydantic-docs.helpmanual.io/usage/schema/#field-cust...