Skip to content

Commit

Permalink
Small addendums to #773
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Feb 28, 2021
1 parent af3045b commit ded9225
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/comparison.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ This is especially useful when you have fields with objects that have atypical c
Common examples of such objects are `NumPy arrays <https://github.com/python-attrs/attrs/issues/435>`_.

Please note that *eq* and *order* are set *independently*, because *order* is `False` by default in `modern APIs <prov>`.
You can set both at once by using the *cmp* argument that we've undeprecated just for this use-case.
11 changes: 6 additions & 5 deletions src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def attrib(
to be ordered.
:type order: a `bool` or a `callable`.
:param cmp: Setting to ``True`` is equivalent to setting ``eq=True,
order=True``. Can also be set to a ``callable``.
:param cmp: Setting *cmp* is equivalent to setting *eq* and *order* to the
same value. Must not be mixed with *eq* or *order*.
:type cmp: a `bool` or a `callable`.
:param Optional[bool] hash: Include this attribute in the generated
Expand Down Expand Up @@ -251,7 +251,8 @@ def attrib(
.. versionadded:: 19.2.0 *eq* and *order*
.. versionadded:: 20.1.0 *on_setattr*
.. versionchanged:: 20.3.0 *kw_only* backported to Python 2
.. versionchanged:: 21.1.0 *eq* and *order* also accept a custom callable
.. versionchanged:: 21.1.0
*eq*, *order*, and *cmp* also accept a custom callable
.. versionchanged:: 21.1.0 *cmp* undeprecated
"""
eq, eq_key, order, order_key = _determine_attrib_eq_order(
Expand Down Expand Up @@ -1258,8 +1259,8 @@ def attrs(
``__gt__``, and ``__ge__`` methods that behave like *eq* above and
allow instances to be ordered. If ``None`` (default) mirror value of
*eq*.
:param Optional[bool] cmp: Setting to ``True`` is equivalent to setting
``eq=True, order=True``. Must not be mixed with *eq* or *order*.
:param Optional[bool] cmp: Setting *cmp* is equivalent to setting *eq*
and *order* to the same value. Must not be mixed with *eq* or *order*.
:param Optional[bool] hash: If ``None`` (default), the ``__hash__`` method
is generated according how *eq* and *frozen* are set.
Expand Down

0 comments on commit ded9225

Please sign in to comment.