Pyantic and Cattrs both suffer with unacceptable issues and footguns. I have used Pydantic in production a lot and have played around with Cattrs. I've also looked at similar libraries like Dacite and marshmallow-dataclasses but none seem to be well thought out and mature. * Neither Pydantic nor Cattrs handle unions like how I'd expect (although Cattrs has stronger guarantees in converting Unions) >>> class Y(BaseMod…
I use Attrs instead of Pydantic
71–76 of 76 posts
Re: I use Attrs instead of Pydantic
#72Quick look and from what I can see attrs/cattrs can't generate jsonschema => game over.
It would be better in the other way. Generate sane python models with it using existing jsonschema - similar to stuff like grpc, but without extra bits. The existing generators are generally terrible.
Re: I use Attrs instead of Pydantic
#73Earlier quoted context omitted.
As of 2021, there is now a complete Pydantic "CRUD stack" (ODMantic/SQLModel + FastAPI) that is ridiculously easy to get up and running with, and it has all of the features one might want in a brave new type safe world. By comparison, the system of tools around Attrs and Cattrs is a bit scattered and underdeveloped. I don't think there's a technical reason for it, that's just how it happened. It would be great to see…
SQLModel is brand new? why not just use sqlalchemy which is more mature?
Re: I use Attrs instead of Pydantic
#74Quick look and from what I can see attrs/cattrs can't generate jsonschema => game over.
It would be better in the other way. Generate sane python models with it using existing jsonschema - similar to stuff like grpc, but without extra bits. The existing generators are generally terrible.
Re: I use Attrs instead of Pydantic
#75Having run into these issues with Pydantic, we've been using Mashumaro[1], which, while not having all the bells and whistles of Pydantic, has served us pretty well. 1: https://github.com/Fatal1ty/mashumaro
Re: I use Attrs instead of Pydantic
#76Earlier quoted context omitted.
If it is a problem, import attr as attrs which is probably what I would do for consistency.
I want never to see the names attr.ib and attr.s in code that I am working on. So I don't understand how your suggestion solves the problem: it might not be me writing the code.