You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- On Python 3.10 and later, call [`abc.update_abstractmethods()`](https://docs.python.org/3/library/abc.html#abc.update_abstractmethods) on dict classes after creation.
Copy file name to clipboardExpand all lines: docs/why.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,10 @@ Whether they're relevant to *you* depends on your circumstances:
19
19
20
20
On the other hand, Data Classes currently do not offer any significant feature that *attrs* doesn't already have.
21
21
22
+
- We are more likely to commit crimes against nature to make things work that one would expect to work, but that are quite complicated.
23
+
24
+
This includes stepping through generated methods using a debugger, cell rewriting to make bare `super()` calls work, or making {func}`functools.cached_property` work on slotted classes.
25
+
22
26
-*attrs* supports all mainstream Python versions including PyPy.
23
27
24
28
-*attrs* doesn't force type annotations on you if you don't like them.
@@ -27,6 +31,7 @@ Whether they're relevant to *you* depends on your circumstances:
27
31
28
32
- While Data Classes are implementing features from *attrs* every now and then, their presence is dependent on the Python version, not the package version.
29
33
For example, support for `__slots__` has only been added in Python 3.10, but it doesn’t do cell rewriting and therefore doesn’t support bare calls to `super()`.
34
+
30
35
This may or may not be fixed in later Python releases, but handling all these differences is especially painful for PyPI packages that support multiple Python versions.
31
36
And of course, this includes possible implementation bugs.
32
37
@@ -48,7 +53,7 @@ However, as convenient as it might be, using it for your business or data layer
48
53
Is it really necessary to re-validate all your objects while reading them from a trusted database?
49
54
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*.
50
55
51
-
[*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.
56
+
[*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 and seen the results of allowing design pressure from the edges of your system, like ORMs or web APIs.
52
57
53
58
*attrs* emphatically does **not** try to be a validation library, but a toolkit to write well-behaved classes like you would write yourself.
54
59
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.
@@ -272,7 +277,7 @@ is roughly
272
277
ArtisanalClass(a=1, b=2)
273
278
```
274
279
275
-
which is quite a mouthful and it doesn't even use any of *attrs*'s more advanced features like validators or default values.
280
+
That's quite a mouthful and it doesn't even use any of *attrs*'s more advanced features like validators or default values.
276
281
Also: no tests whatsoever.
277
282
And who will guarantee you, that you don't accidentally flip the `<` in your tenth implementation of `__gt__`?
0 commit comments