From 358c85e74c5e9c73a222268cb34c914c52135497 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Fri, 21 Aug 2020 05:19:15 +0200 Subject: [PATCH] Fix auto-detection of eq/ne in NG APIs (#671) Fixes #670 --- src/attr/_next_gen.py | 2 +- tests/test_next_gen.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/attr/_next_gen.py b/src/attr/_next_gen.py index b0aefe310..57e8635b1 100644 --- a/src/attr/_next_gen.py +++ b/src/attr/_next_gen.py @@ -28,7 +28,7 @@ def define( kw_only=False, cache_hash=False, auto_exc=True, - eq=True, + eq=None, order=False, auto_detect=True, getstate_setstate=None, diff --git a/tests/test_next_gen.py b/tests/test_next_gen.py index e350498a3..a4460b192 100644 --- a/tests/test_next_gen.py +++ b/tests/test_next_gen.py @@ -133,3 +133,18 @@ class F: with pytest.raises(attr.exceptions.FrozenInstanceError): f.x = 2 + + def test_auto_detect_eq(self): + """ + auto_detect=True works for eq. + + Regression test for #670. + """ + + @attr.define + class C: + def __eq__(self, o): + raise ValueError() + + with pytest.raises(ValueError): + C() == C()