Skip to content

Commit

Permalink
Polish up #627
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Feb 22, 2021
1 parent aefdb11 commit 44ac461
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/627.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It's now possible to customize the behavior of ``eq`` and ``order`` by passing in a callable.
6 changes: 2 additions & 4 deletions src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def _add_method_dunders(self, method):
)

_EQ_ORDER_CUSTOMIZATION = (
"You have customized the behaviour of `eq` but not of `order`. "
"You have customized the behavior of `eq` but not of `order`. "
"This is probably a bug."
)

Expand Down Expand Up @@ -2484,7 +2484,7 @@ class Attribute(object):
.. versionadded:: 20.1.0 *on_setattr*
.. versionchanged:: 20.2.0 *inherited* is not taken into account for
equality checks and hashing anymore.
.. versionadded:: 20.X.Y *eq_key* and *order_key*
.. versionadded:: 21.1.0 *eq_key* and *order_key*
For the full version history of the fields, see `attr.ib`.
"""
Expand Down Expand Up @@ -2660,9 +2660,7 @@ def _setattrs(self, name_values_pairs):
repr=True,
cmp=None,
eq=True,
# eq_key=None,
order=False,
# order_key=None,
hash=(name != "metadata"),
init=True,
inherited=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ def test_order_missing_and_custom_eq(self):
(w,) = wr.list

assert (
"You have customized the behaviour of `eq` but not of `order`. "
"You have customized the behavior of `eq` but not of `order`. "
"This is probably a bug." == w.message.args[0]
)

Expand Down

0 comments on commit 44ac461

Please sign in to comment.