From 9ba7fad855996da483674fc59d9432ec7080e0f8 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Tue, 13 Jun 2023 09:59:16 +0200 Subject: [PATCH] Update Pydantic to their new capitalization style --- docs/why.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/why.md b/docs/why.md index 6e4fde8b..34be3029 100644 --- a/docs/why.md +++ b/docs/why.md @@ -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?