Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37ac3ef

Browse files
committed
docs: improve why
1 parent be30152 commit 37ac3ef

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ See https://github.com/python-attrs/attrs/blob/main/.github/CONTRIBUTING.md#chan
128128
- `attrs.has()` is now a [`TypeGuard`](https://docs.python.org/3/library/typing.html#typing.TypeGuard) for `AttrsInstance`.
129129
That means that type checkers know a class is an instance of an `attrs` class if you check it using `attrs.has()` (or `attr.has()`) first.
130130
[#997](https://github.com/python-attrs/attrs/issues/997)
131-
- Made `attrs.AttrsInstance` stub available at runtime and fixed type errors related to the usage of `attrs.AttrsInstance` in *Pyright*.
131+
- Made `attrs.AttrsInstance` stub available at runtime and fixed type errors related to the usage of `attrs.AttrsInstance` in Pyright.
132132
[#999](https://github.com/python-attrs/attrs/issues/999)
133133
- 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.
134134
This improves the detection of abstractness.

docs/why.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Whether they're relevant to *you* depends on your circumstances:
1919

2020
On the other hand, Data Classes currently do not offer any significant feature that *attrs* doesn't already have.
2121

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+
2226
- *attrs* supports all mainstream Python versions including PyPy.
2327

2428
- *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:
2731

2832
- While Data Classes are implementing features from *attrs* every now and then, their presence is dependent on the Python version, not the package version.
2933
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+
3035
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.
3136
And of course, this includes possible implementation bugs.
3237

@@ -48,7 +53,7 @@ However, as convenient as it might be, using it for your business or data layer
4853
Is it really necessary to re-validate all your objects while reading them from a trusted database?
4954
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*.
5055

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.
5257

5358
*attrs* emphatically does **not** try to be a validation library, but a toolkit to write well-behaved classes like you would write yourself.
5459
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
272277
ArtisanalClass(a=1, b=2)
273278
```
274279

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.
276281
Also: no tests whatsoever.
277282
And who will guarantee you, that you don't accidentally flip the `<` in your tenth implementation of `__gt__`?
278283

0 commit comments

Comments
 (0)