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
Copy file name to clipboardExpand all lines: docs/names.rst
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ In the wake of all of that, `glyph <https://twitter.com/glyph>`_ and `Hynek <htt
43
43
At this point the plan was not to make ``attrs`` what it is now -- a flexible class building kit.
44
44
All we wanted was an ergonomic little library to succinctly define classes with attributes.
45
45
46
-
Under the impression of of the unwieldy ``characteristic`` name, we went to the other side and decided to make the package name part of the API, and keep the API functions very short.
46
+
Under the impression of the unwieldy ``characteristic`` name, we went to the other side and decided to make the package name part of the API, and keep the API functions very short.
47
47
This led to the infamous `attr.s` and `attr.ib` which some found confusing and pronounced it as "attr dot s" or used a singular ``@s`` as the decorator.
48
48
But it was really just a way to say ``attrs`` and ``attrib``\ [#attr]_.
49
49
@@ -72,7 +72,7 @@ A big change happened in May 2017 when Hynek sat down with `Guido van Rossum <ht
72
72
Type annotations for class attributes have `just landed <https://www.python.org/dev/peps/pep-0526/>`_ in Python 3.6 and Guido felt like it would be a good mechanic to introduce something similar to ``attrs`` to the Python standard library.
73
73
The result, of course, was `PEP 557 <https://www.python.org/dev/peps/pep-0557/>`_\ [#stdlib]_ which eventually became the `dataclasses` module in Python 3.7.
74
74
75
-
``attrs`` at this point was lucky to have several people on board who were also very excited about type annotations and helped implementing it; including a `Mypy plugin <https://medium.com/@Pilot-EPD-Blog/mypy-and-attrs-e1b0225e9ac6>`_.
75
+
``attrs`` at this point was lucky to have several people on board who were also very excited about type annotations and helped implement it; including a `Mypy plugin <https://medium.com/@Pilot-EPD-Blog/mypy-and-attrs-e1b0225e9ac6>`_.
76
76
And so it happened that ``attrs`` `shipped <https://www.attrs.org/en/17.3.0.post2/changelog.html>`_ the new method of defining classes more than half a year before Python 3.7 -- and thus `dataclasses` -- were released.
77
77
78
78
-----
@@ -90,7 +90,7 @@ We're determined to serve both.
90
90
^^^^^^^^^^^^^
91
91
92
92
Over its existence, ``attrs`` never stood still.
93
-
But since we also greatly care about backward compatibility and not breaking our users's code, many features and niceties have to be manually activated.
93
+
But since we also greatly care about backward compatibility and not breaking our users' code, many features and niceties have to be manually activated.
94
94
95
95
That is not only annoying, it also leads to the problem that many of ``attrs``'s users don't even know what it can do for them.
96
96
We've spent years alone explaining that defining attributes using type annotations is in no way unique to `dataclasses`.
Copy file name to clipboardExpand all lines: docs/python-2.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Feasibility in this case means:
12
12
1. Possibility to run the tests on our development computers,
13
13
2. and **free** CI options.
14
14
15
-
This can mean that we will have to run our tests on PyPy, whose maintainters have unequivocally declared that they do not intend to stop the development and maintenance of their Python 2-compatible line at all.
15
+
This can mean that we will have to run our tests on PyPy, whose maintainers have unequivocally declared that they do not intend to stop the development and maintenance of their Python 2-compatible line at all.
16
16
And this can mean that at some point, a sponsor will have to step up and pay for bespoke CI setups.
17
17
18
18
**However**: there is no promise of new features coming to ``attrs`` running under Python 2.
Copy file name to clipboardExpand all lines: docs/types.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ You can choose freely between the approaches, but please remember that if you ch
22
22
23
23
----
24
24
25
-
Even when going all-in an type annotations, you will need `attr.field` for some advanced features though.
25
+
Even when going all-in on type annotations, you will need `attr.field` for some advanced features though.
26
26
27
27
One of those features are the decorator-based features like defaults.
28
28
It's important to remember that ``attrs`` doesn't do any magic behind your back.
@@ -42,7 +42,7 @@ If you need to resolve these to real types, you can call `attrs.resolve_types` w
42
42
43
43
In practice though, types show their biggest usefulness in combination with tools like mypy_, pytype_, or pyright_ that have dedicated support for ``attrs`` classes.
44
44
45
-
The addition of static types is certainly one of the most exciting features in the Python ecosystem and helps you writing *correct* and *verified self-documenting* code.
45
+
The addition of static types is certainly one of the most exciting features in the Python ecosystem and helps you write *correct* and *verified self-documenting* code.
46
46
47
47
If you don't know where to start, Carl Meyer gave a great talk on `Type-checked Python in the Real World <https://www.youtube.com/watch?v=pMgmKJyWKn8>`_ at PyCon US 2018 that will help you to get started in no time.
Copy file name to clipboardExpand all lines: docs/why.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ Basically what ``attrs`` was in 2015.
39
39
…pydantic?
40
40
----------
41
41
42
-
*pydantic* is first an foremost a *data validation library*.
42
+
*pydantic* is first and foremost a *data validation library*.
43
43
As such, it is a capable complement to class building libraries like ``attrs`` (or Data Classes!) for parsing and validating untrusted data.
44
44
45
45
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/>`_:
@@ -89,7 +89,7 @@ Other often surprising behaviors include:
89
89
- Iterability also implies that it's easy to accidentally unpack a ``namedtuple`` which leads to hard-to-find bugs. [#iter]_
90
90
- ``namedtuple``\ s have their methods *on your instances* whether you like it or not. [#pollution]_
91
91
- ``namedtuple``\ s are *always* immutable.
92
-
Not only does that mean that you can't decide for yourself whether your instances should be immutable or not, it also means that if you want to influence your class' initialization (validation? default values?), you have to implement :meth:`__new__() <object.__new__>` which is a particularly hacky and error-prone requirement for a very common problem. [#immutable]_
92
+
Not only does that mean that you can't decide for yourself whether your instances should be immutable or not, it also means that if you want to influence your class' initialization (validation? default values?), you have to implement :meth:`__new__() <object.__new__>` which is a particularly hacky and error-prone requirement for a very common problem. [#immutable]_
93
93
- To attach methods to a ``namedtuple`` you have to subclass it.
94
94
And if you follow the standard library documentation's recommendation of::
0 commit comments