Skip to content

Commit f47e568

Browse files
authored
Make NG APIs official (#786)
1 parent 6d1d5e9 commit f47e568

5 files changed

Lines changed: 25 additions & 18 deletions

File tree

changelog.d/668.change.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The instant favorite `next-generation APIs <https://www.attrs.org/en/stable/api.html#next-gen>`_ are not provisional anymore!
2+
3+
They are also officially supported by Mypy as of their `0.800 release <https://mypy-lang.blogspot.com/2021/01/mypy-0800-released.html>`_.
4+
5+
We hope the next release will already contain an (additional) importable package called ``attrs``.

changelog.d/786.change.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The instant favorite `next-generation APIs <https://www.attrs.org/en/stable/api.html#next-gen>`_ are not provisional anymore!
2+
3+
They are also officially supported by Mypy as of their `0.800 release <https://mypy-lang.blogspot.com/2021/01/mypy-0800-released.html>`_.
4+
5+
We hope the next release will already contain an (additional) importable package called ``attrs``.

docs/api.rst

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ Core
1717
----
1818

1919

20-
.. warning::
21-
As of ``attrs`` 20.1.0, it also ships with a bunch of provisional APIs that are intended to become the main way of defining classes in the future.
20+
.. note::
21+
22+
``attrs`` 20.1.0 added a bunch of nicer APIs (sometimes referred to as next generation -- or NG -- APIs) that were intended to become the main way of defining classes in the future.
23+
As of 21.1.0, they are not provisional anymore and are the **recommended** way to use ``attrs``!
24+
The next step will be adding an importable ``attrs`` namespace.
25+
The documentation will be updated successively.
2226

23-
Please have a look at :ref:`prov`.
27+
Please have a look at :ref:`next-gen`!
2428

2529
.. autodata:: attr.NOTHING
2630

@@ -578,12 +582,12 @@ These are helpers that you can use together with `attr.s`'s and `attr.ib`'s ``on
578582
N.B. Please use `attr.s`'s *frozen* argument to freeze whole classes; it is more efficient.
579583

580584

581-
.. _prov:
585+
.. _next-gen:
582586

583-
Provisional APIs
584-
----------------
587+
Next Generation APIs
588+
--------------------
585589

586-
These are Python 3.6 and later-only, keyword-only, and **provisional** APIs that call `attr.s` with different default values.
590+
These are Python 3.6 and later-only, and keyword-only APIs that call `attr.s` with different default values.
587591

588592
The most notable differences are:
589593

@@ -597,14 +601,9 @@ The most notable differences are:
597601

598602
Please note that these are *defaults* and you're free to override them, just like before.
599603

600-
----
601-
602-
Their behavior is scheduled to become part of the upcoming ``import attrs`` that will introduce a new namespace with nicer names and nicer defaults (see `#408 <https://github.com/python-attrs/attrs/issues/408>`_ and `#487 <https://github.com/python-attrs/attrs/issues/487>`_).
603-
604-
Therefore your constructive feedback in the linked issues above is strongly encouraged!
604+
Since the Python ecosystem has settled on the term ``field`` for defining attributes, we have also added `attr.field` as a substitute for `attr.ib`.
605605

606606
.. note::
607-
Provisional doesn't mean we will remove it (although it will be deprecated once the final form is released), but that it might change if we receive relevant feedback.
608607

609608
`attr.s` and `attr.ib` (and their serious business cousins) aren't going anywhere.
610609
The new APIs build on top of them.

docs/comparison.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ It is then used as a key function like you may know from `sorted`:
4242
This is especially useful when you have fields with objects that have atypical comparison properties.
4343
Common examples of such objects are `NumPy arrays <https://github.com/python-attrs/attrs/issues/435>`_.
4444

45-
Please note that *eq* and *order* are set *independently*, because *order* is `False` by default in `modern APIs <prov>`.
45+
Please note that *eq* and *order* are set *independently*, because *order* is `False` by default in `modern APIs <next-gen>`.
4646
You can set both at once by using the *cmp* argument that we've undeprecated just for this use-case.

src/attr/_next_gen.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
2-
This is a Python 3.6 and later-only, keyword-only, and **provisional** API that
3-
calls `attr.s` with different default values.
4-
5-
Provisional APIs that shall become "import attrs" one glorious day.
2+
These are Python 3.6+-only and keyword-only APIs that call `attr.s` and
3+
`attr.ib` with different default values.
64
"""
75

86
from functools import partial

0 commit comments

Comments
 (0)