HACKER Q&A
📣 behnamoh

Pydantic has too much deprecation. Why is it popular?


Almost all tutorials I see online (and ChatGPT's knowledge base) teach you Pydantic v1. There are numerous things that are deprecated during transition to v2 (@root_validator, @validator, using 'always', etc. are all gone now.). I even found a code example on its Github from November 2023 which now throws an error, saying that FieldValidationInfo is deprecated now, use instead...

I wanted to use something to validate user inputs to my API, but getting Pydantic right and then keeping it updated has been too much unnecessary work, which makes me wonder if you have also faced this problem and what your solution is?


  👤 minimaxir Accepted Answer ✓
Pydantic's v1 to v2 was due to a full rewrite/port to Rust. Lots of depreciations are expected in that instance, and it's not common for a popular library and will likely not happen again.

Deprecations are healthy, otherwise you get technical debt which harms development.


👤 mejutoco
I like Pydantic, but it is true it broke too many things.

It is not the same, but typeguard has runtime typechecks with the @typechecked function annotation. Mypy checks help as well.


👤 botanicalfriend
From my perspective a large factor contributing to its popularity is because of FastAPIs native integration. V2 has broken so much behavior, and the library is generally fragile and slow. Credit where it is due, it is a great library that has done a lot to bring python types to more projects, but there are better solutions out there now.

I’d strongly recommend looking into msgspec. It is a much faster alternative and is largely “correct” in its implementation. It uses all of the python native type annotations without many hacks. Really it is much much faster and can actually be used for performance sensitive python workloads that need strong typing.


👤 scolvin
Pydantic author here.

Pydantic won't change again significantly, so it won't be any effort to keep it up-to-date.

There were good reasons to make all the changes made in the V1->V2 upgrade, I think those are pretty clear.

I think Pydantic is popular because of it's extremely flexible/powerful while also being intuitive to get started with.


👤 sk11001
Is the complaint that v1 and v2 are different? Why are you learning v1 at all?