Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update attrs to 21.2.0 #456

Closed
wants to merge 1 commit into from
Closed

Conversation

pyup-bot
Copy link
Collaborator

@pyup-bot pyup-bot commented May 8, 2021

This PR updates attrs from 20.2.0 to 21.2.0.

Changelog

21.2.0

-------------------

Backward-incompatible Changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- We had to revert the recursive feature for ``attr.evolve()`` because it broke some use-cases -- sorry!
`806 <https://github.com/python-attrs/attrs/issues/806>`_
- Python 3.4 is now blocked using packaging metadata because ``attrs`` can't be imported on it anymore.
To ensure that 3.4 users can keep installing  ``attrs`` easily, we will `yank <https://pypi.org/help/#yanked>`_ 21.1.0 from PyPI.
This has **no** consequences if you pin ``attrs`` to 21.1.0.
`807 <https://github.com/python-attrs/attrs/issues/807>`_


----

21.1.0

-------------------

Deprecations
^^^^^^^^^^^^

- The long-awaited, much-talked-about, little-delivered ``import attrs`` is finally upon us!

Since the NG APIs have now been proclaimed stable, the **next** release of ``attrs`` will allow you to actually ``import attrs``.
We're taking this opportunity to replace some defaults in our APIs that made sense in 2015, but don't in 2021.

So please, if you have any pet peeves about defaults in ``attrs``'s APIs, *now* is the time to air your grievances in 487!
We're not gonna get such a chance for a second time, without breaking our backward-compatibility guarantees, or long deprecation cycles.
Therefore, speak now or forever hold you peace!
`487 <https://github.com/python-attrs/attrs/issues/487>`_
- The *cmp* argument to ``attr.s()`` and `attr.ib()` has been **undeprecated**
It will continue to be supported as syntactic sugar to set *eq* and *order* in one go.

I'm terribly sorry for the hassle around this argument!
The reason we're bringing it back is it's usefulness regarding customization of equality/ordering.

The ``cmp`` attribute and argument on ``attr.Attribute`` remains deprecated and will be removed later this year.
`773 <https://github.com/python-attrs/attrs/issues/773>`_


Changes
^^^^^^^

- It's now possible to customize the behavior of ``eq`` and ``order`` by passing in a callable.
`435 <https://github.com/python-attrs/attrs/issues/435>`_,
`627 <https://github.com/python-attrs/attrs/issues/627>`_
- The instant favorite `next-generation APIs <https://www.attrs.org/en/stable/api.html#next-gen>`_ are not provisional anymore!

They are also officially supported by Mypy as of their `0.800 release <https://mypy-lang.blogspot.com/2021/01/mypy-0800-released.html>`_.

We hope the next release will already contain an (additional) importable package called ``attrs``.
`668 <https://github.com/python-attrs/attrs/issues/668>`_,
`786 <https://github.com/python-attrs/attrs/issues/786>`_
- If an attribute defines a converter, the type of its parameter is used as type annotation for its corresponding ``__init__`` parameter.

If an ``attr.converters.pipe`` is used, the first one's is used.
`710 <https://github.com/python-attrs/attrs/issues/710>`_
- Fixed the creation of an extra slot for an ``attr.ib`` when the parent class already has a slot with the same name.
`718 <https://github.com/python-attrs/attrs/issues/718>`_
- ``__attrs__init__()`` will now be injected if ``init=False``, or if ``auto_detect=True`` and a user-defined ``__init__()`` exists.

This enables users to do "pre-init" work in their ``__init__()`` (such as ``super().__init__()``).

``__init__()`` can then delegate constructor argument processing to ``self.__attrs_init__(*args, **kwargs)``.
`731 <https://github.com/python-attrs/attrs/issues/731>`_
- ``bool(attr.NOTHING)`` is now ``False``.
`732 <https://github.com/python-attrs/attrs/issues/732>`_
- It's now possible to use ``super()`` inside of properties of slotted classes.
`747 <https://github.com/python-attrs/attrs/issues/747>`_
- Allow for a ``__attrs_pre_init__()`` method that -- if defined -- will get called at the beginning of the ``attrs``-generated ``__init__()`` method.
`750 <https://github.com/python-attrs/attrs/issues/750>`_
- Added forgotten ``attr.Attribute.evolve()`` to type stubs.
`752 <https://github.com/python-attrs/attrs/issues/752>`_
- ``attrs.evolve()`` now works recursively with nested ``attrs`` classes.
`759 <https://github.com/python-attrs/attrs/issues/759>`_
- Python 3.10 is now officially supported.
`763 <https://github.com/python-attrs/attrs/issues/763>`_
- ``attr.resolve_types()`` now takes an optional *attrib* argument to work inside a ``field_transformer``.
`774 <https://github.com/python-attrs/attrs/issues/774>`_
- ``ClassVar``\ s are now also detected if they come from `typing-extensions <https://pypi.org/project/typing-extensions/>`_.
`782 <https://github.com/python-attrs/attrs/issues/782>`_
- To make it easier to customize attribute comparison (435), we have added the ``attr.cmp_with()`` helper.

See the `new docs on comparison <https://www.attrs.org/en/stable/comparison.html>`_ for more details.
`787 <https://github.com/python-attrs/attrs/issues/787>`_
- Added **provisional** support for static typing in ``pyright`` via the `dataclass_transforms specification <https://github.com/microsoft/pyright/blob/master/specs/dataclass_transforms.md>`_.
Both the ``pyright`` specification and ``attrs`` implementation may change in future versions of both projects.

Your constructive feedback is welcome in both `attrs795 <https://github.com/python-attrs/attrs/issues/795>`_ and `pyright#1782 <https://github.com/microsoft/pyright/discussions/1782>`_.
`796 <https://github.com/python-attrs/attrs/issues/796>`_


----

20.3.0

-------------------

Backward-incompatible Changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- ``attr.define()``, ``attr.frozen()``, ``attr.mutable()``, and ``attr.field()`` remain **provisional**.

This release does **not** change change anything about them and they are already used widely in production though.

If you wish to use them together with mypy, you can simply drop `this plugin <https://gist.github.com/hynek/1e3844d0c99e479e716169034b5fa963#file-attrs_ng_plugin-py>`_ into your project.

Feel free to provide feedback to them in the linked issue 668.

We will release the ``attrs`` namespace once we have the feeling that the APIs have properly settled.
`668 <https://github.com/python-attrs/attrs/issues/668>`_


Changes
^^^^^^^

- ``attr.s()`` now has a *field_transformer* hook that is called for all ``Attribute``\ s and returns a (modified or updated) list of ``Attribute`` instances.
``attr.asdict()`` has a *value_serializer* hook that can change the way values are converted.
Both hooks are meant to help with data (de-)serialization workflows.
`653 <https://github.com/python-attrs/attrs/issues/653>`_
- ``kw_only=True`` now works on Python 2.
`700 <https://github.com/python-attrs/attrs/issues/700>`_
- ``raise from`` now works on frozen classes on PyPy.
`703 <https://github.com/python-attrs/attrs/issues/703>`_,
`712 <https://github.com/python-attrs/attrs/issues/712>`_
- ``attr.asdict()`` and ``attr.astuple()`` now treat ``frozenset``\ s like ``set``\ s with regards to the *retain_collection_types* argument.
`704 <https://github.com/python-attrs/attrs/issues/704>`_
- The type stubs for ``attr.s()`` and ``attr.make_class()`` are not missing the *collect_by_mro* argument anymore.
`711 <https://github.com/python-attrs/attrs/issues/711>`_


----
Links

@pyup-bot pyup-bot mentioned this pull request May 8, 2021
@pyup-bot
Copy link
Collaborator Author

Closing this in favor of #503

@pyup-bot pyup-bot closed this Dec 28, 2021
@Emantor Emantor deleted the pyup-update-attrs-20.2.0-to-21.2.0 branch December 28, 2021 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant