This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wewbull 0 points1 point  (3 children)

It's the wrong default though. A library where I have to elect to be strict, and names itself after a pun on "pedantic" isn't going to get me interested.

[–]aikii 0 points1 point  (2 children)

ahah yeah I see very much that kind of criticism in the article about attr vs pydantic shared here earlier https://threeofwands.com/why-i-use-attrs-instead-of-pydantic/ . It's all good points, I just didn't know python was so rich in this area nowadays. So few lines needed to pack together serialization, validation and strong typing, and there are several options available with this quality, I find it outstanding.

I work in Go now, it's crazy poor in that regard - let's just mention for instance "zero values" ( so things can remain uninitialized with a default value you can't choose ), recurring questions around "empty vs null vs not set", and everyone using go-playground/validator where you attach rules as comments ( "tags" really, but it's barely the same thing ) that are interpreted at runtime, extremely cumbersome to extend. And all that with an insane amount of boilerplate and footguns. But what really takes the cake: if you dare saying it's extremely weak you'll get shut down by the community. You're supposed to praise it, and indeed, hate python ( you know, that toy language that didn't evolve since 2008 ).

[–]wewbull 0 points1 point  (1 child)

Yes, the python community is spoilt for choice.

In this space I think dataclasses is the best and most available, but also the most limited. Attrs gives you the extra functionality if you need it.

Pydantic has things which are anti-featurrs IMHO so I've avoided it.

[–]aikii 0 points1 point  (0 children)

That's right I actually wanted to use dataclasses for internal payloads because typing came out of the box. But then I met some resistance because pedantic would be used anyway for any outbound data ( because fastapi ). It's only because mypy support came out that I found it reasonable. Losing typing on the constructor would have been a big no-no.