Stress optionality

This commit is contained in:
Hynek Schlawack 2021-12-24 14:33:02 +01:00
parent e8f552c6f0
commit d9ed03a751
1 changed files with 5 additions and 1 deletions

View File

@ -82,9 +82,13 @@ Never again violate the `single responsibility principle <https://en.wikipedia.o
----
**Hate type annotations**!?
No problem!
With ``attrs`` types are entirely **optional**.
Simply assign `field()` to the attributes instead of annotating them with types.
In case you're wondering: this example uses ``attrs``'s `modern APIs <https://www.attrs.org/en/stable/api.html#next-generation-apis>`_ that have been introduced in version 20.1.0.
The classic APIs (``@attr.s``, ``attr.ib``, ``@attr.attrs``, ``attr.attrib``, and ``attr.dataclass``) will remain indefinitely.
`Type annotations <https://www.attrs.org/en/latest/types.html>`_ will also stay entirely **optional** forever.
Please check out `On The Core API Names <https://www.attrs.org/en/latest/names.html>`_ for a more in-depth explanation.