diff --git a/changelog.d/627.change.rst b/changelog.d/627.change.rst new file mode 100644 index 000000000..9286afddc --- /dev/null +++ b/changelog.d/627.change.rst @@ -0,0 +1 @@ +It's now possible to customize the behavior of ``eq`` and ``order`` by passing in a callable. diff --git a/src/attr/_make.py b/src/attr/_make.py index 44362c85d..ebbc061c3 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -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." ) @@ -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`. """ @@ -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, diff --git a/tests/test_make.py b/tests/test_make.py index c9085c77b..05d0530ab 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -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] )