3 ms·
I agree, I don't love Pydantic. I much prefer the "stack" of Attrs + Marshmallow + Desert + Apispec. More tools, yes, but they compose nicely and they each do o
by nerdponx 6y ago
I agree, I don't love Pydantic. I much prefer the "stack" of Attrs + Marshmallow + Desert + Apispec. More tools, yes, but they compose nicely and they each do one thing well. Now where have I heard that one before...
I wish FastAPI had chosen that path instead of Pydantic, but here we are. FastAPI itself is a wonderful tool, with wonderful docs.
is it possible that pydantic is colliding with the steering council because it's misusing the annotations feature?
Yes.
There are lots of good reasons why types aren't necessarily a great match with runtime validation.
It gets the whole thing backwards IMO; I want to be erasing types at runtime and verifying them ahead-of-time. If I consume a piece of data that might be the wrong type, I want to explicitly validate the data myself, and return the desired type if and only if my validation passes. This is the Attrs approach and it works much better, even if you have to put in a few extra keystrokes in the handful of situations when you want explicit validation upon every class instantiation.
Moreover, making annotations lazy is not mindless adherence to purity or some kind of intended "fuck you" to the Pydantic ecosystem. PEP 649 clearly states its motivations. Type annotations have always been a static analysis tool first and foremost, and I think it's absolutely wrong to even suggest that CPython should suffer a higher maintenance burden and suboptimal performance to support what is effectively an off-label usage.
- kortex 6y agoTo each their own. I dislike Marshmallow and I adore pydantic. Runtime validation that aligns with static types makes sense to my brain, and keeps me from losing my mind in a complex system. I don't think making the type annotations lazy is a "fuck you" to pydantic, but it is a breaking change on a minor revision.
- williamsmj 6y agoWell, it is a breaking change on a minor revision, but Python doesn't use semantic versioning so there's no reason that can't happen. The relevant PEP, https://www.python.org/dev/peps/pep-0387/ https://www.python.org/dev/peps/pep-0387/, states that breaking changes may be made with two minor versions of warning (or one major version). Minor versions are released on a calendar schedule (again, not semantic versioning), so this policy is 2-3 years of warning in practice.
- mixmastamyk 6y agoWhich again is a poor way to go about things.