News for hackers. Stuff that matters.
Re:I use Attrs instead of Pydantic by nerdponx on Thursday August 26, 2021 @08:41AM (#28314190)
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 either a competitive parallel "stack" developing, or increased interoperability from libraries that currently only support one or the other.

For this reason, in my personal projects I use Attrs almost all the time when writing new classes. I don't use Pydantic. But at work, we are very likely going to adopt the aforementioned "Pydantic CRUD stack" for new internal services, specifically because our needs are straightforward, and for straightforward use case is a "just works" and "there's only one right way to do it", which I think are extremely valuable features when operating in a team.

Re:I use Attrs instead of Pydantic by maleldil on Thursday August 26, 2021 @09:02AM (#28314380)
What's the use case for Attrs in a post-dataclasses world? I use dataclasses all the time, and I've never felt the need to reach for Attrs. What am I missing out on?
Re:I use Attrs instead of Pydantic by nerdponx on Thursday August 26, 2021 @09:06AM (#28314412)
More configurability, slots by default, faster to create the class object. I've heard stories that loading a module with a lot of dataclasses defined in it can be really slow. Basically dataclasses are for the people who can't afford a 3rd-party dependency for whatever reason.
Re:I use Attrs instead of Pydantic by zbentley on Thursday August 26, 2021 @10:16AM (#28315267)
Substantially more customization hooks in attrs.
Re:I use Attrs instead of Pydantic by mdellavo on Thursday August 26, 2021 @12:00PM (#28316660)
SQLModel is brand new? why not just use sqlalchemy which is more mature?
Re:I use Attrs instead of Pydantic by rekwah on Thursday August 26, 2021 @01:43PM (#28318070)
SQLModel is a glue/shim layer for defining models that are both pydantic & SA compatible so you don't have to duplicate the effort.
Re:I use Attrs instead of Pydantic by nerdponx on Thursday August 26, 2021 @06:25PM (#28321791)
The former wraps the latter, I think.