Update Pydantic to their new capitalization style

This commit is contained in:
Hynek Schlawack 2023-06-13 09:59:16 +02:00
parent 0a02d34f57
commit 9ba7fad855
No known key found for this signature in database
GPG Key ID: AE2536227F69F181
1 changed files with 6 additions and 3 deletions

View File

@ -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. 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. 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/): 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? 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. [*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? ## … namedtuples?