Skip to content

Commit

Permalink
Update Pydantic to their new capitalization style
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jun 13, 2023
1 parent 0a02d34 commit 9ba7fad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/why.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ One way to think about *attrs* vs Data Classes is that *attrs* is a fully-fledge
Basically what *attrs* was in 2015.


## pydantic?
## Pydantic?

*pydantic* is first and foremost a *data validation library*.
Pydantic is first and foremost a *data validation & type coercion library*.
As such, it is a capable complement to class building libraries like *attrs* (or Data Classes!) for parsing and validating untrusted data.

However, as convenient as it might be, using it for your business or data layer [is problematic in several ways](https://threeofwands.com/why-i-use-attrs-instead-of-pydantic/):
Is it really necessary to re-validate all your objects while reading them from a trusted database?
In the parlance of [*Form, Command, and Model Validation*](https://verraes.net/2015/02/form-command-model-validation/), *pydantic* is the right tool for *Commands*.
In the parlance of [*Form, Command, and Model Validation*](https://verraes.net/2015/02/form-command-model-validation/), Pydantic is the right tool for *Commands*.

[*Separation of concerns*](https://en.wikipedia.org/wiki/Separation_of_concerns) feels tedious at times, but it's one of those things that you get to appreciate once you've shot your own foot often enough.

*attrs* emphatically does **not** try to be a validation library, but a toolkit to write well-behaved classes like you would write yourself.
If you'd like a powerful library for structuring, unstructuring, and validating data, have a look at [*cattrs*](https://catt.rs/) which is an official member of the *attrs* family.


## … namedtuples?

Expand Down

0 comments on commit 9ba7fad

Please sign in to comment.