From 44ac46114603f8fa7c1142dd338da16c5373d8df Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 22 Feb 2021 08:59:09 +0100 Subject: [PATCH] Polish up #627 --- changelog.d/627.change.rst | 1 + src/attr/_make.py | 6 ++---- tests/test_make.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 changelog.d/627.change.rst 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] )