News for hackers. Stuff that matters.
Re:I use Attrs instead of Pydantic by andrewingram on Thursday August 26, 2021 @05:23AM (#28312498)
Thanks, I've had a look at Marshmallow in the past, but it's still doing the extra bits of dealing with the extra bits of serialization, it never really felt all that dissimilar to Pydantic.

What I've really been looking for something that I can just use to check a data structure i'm passing in to a function call is valid. One use case is related to state machines, where I'm providing some data along with a transition name, and want to make sure the combination of transition + data is valid.

Re:I use Attrs instead of Pydantic by radus on Thursday August 26, 2021 @09:25AM (#28314586)
Pedantic has a validate_arguments decorator that while in beta, I think does what you want: https://pydantic-docs.helpmanual.io/usage/validation_decorat...
Re:I use Attrs instead of Pydantic by nkconway on Thursday August 26, 2021 @04:18PM (#28320103)
I have used a combo of attrs and fastjsonschema to do dataclass validation on instance construction.

It works great for a python stack and you can generate some clean looking code if you have a reusable data class package

Re:I use Attrs instead of Pydantic by nerdponx on Thursday August 26, 2021 @07:54AM (#28313725)
Design-by-contract, perhaps? There are a couple libraries like this currently, and you could pretty easily write your own framework for it.

Also, Attrs and Pydantic both support arbitrary additional validation on fields.

Re:I use Attrs instead of Pydantic by bilboa on Thursday August 26, 2021 @09:40AM (#28314793)
Sounds like you want jsonschema.