attrs/changelog.d/574.deprecation.rst

12 lines
744 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The ``cmp`` argument to ``attr.s()`` and ``attr.ib()`` is now deprecated.
Please use ``eq`` to add equality methods (``__eq__`` and ``__ne__``) and ``order`` to add ordering methods (``__lt__``, ``__le__``, ``__gt__``, and ``__ge__``) instead just like with `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_.
Both are effectively ``True`` by default but it's enough to set ``eq=False`` to disable both at once.
Passing ``eq=False, order=True`` explicitly will raise a ``ValueError`` though.
Since this is arguably a deeper backward-compatibility break, it will have an extended deprecation period until 2021-06-01.
After that day, the ``cmp`` argument will be removed.
``attr.Attribute`` also isn't orderable anymore.