From 75ea943f60e934f6bd6fde44c3d35eca67092ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Tue, 5 Mar 2024 19:27:23 +0100 Subject: [PATCH] improve CAHBI --- satella/coding/structures/mixins/hashable.py | 9 +++------ tests/test_coding/test_structures.py | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/satella/coding/structures/mixins/hashable.py b/satella/coding/structures/mixins/hashable.py index ff1c4106..41561f2e 100644 --- a/satella/coding/structures/mixins/hashable.py +++ b/satella/coding/structures/mixins/hashable.py @@ -181,19 +181,16 @@ class OmniHashableMixin(metaclass=ABCMeta): """ Note that this will only compare _HASH_FIELDS_TO_USE """ - return _generic_eq(self, other, False, operator.eq, 'eq', ) + return _generic_eq(self, other, False, operator.eq) def __ne__(self, other) -> bool: - return _generic_eq(self, other, True, operator.ne, 'ne') + return _generic_eq(self, other, True, operator.ne) -def _generic_eq(self, other, truth, comparator, name): +def _generic_eq(self, other, truth, comparator): if not isinstance(other, type(self)): return truth - if not isinstance(other, OmniHashableMixin): - return comparator(self, other) - cmpr_by = self._HASH_FIELDS_TO_USE try: if isinstance(cmpr_by, str): diff --git a/tests/test_coding/test_structures.py b/tests/test_coding/test_structures.py index 0fa0be56..d5734587 100644 --- a/tests/test_coding/test_structures.py +++ b/tests/test_coding/test_structures.py @@ -275,7 +275,7 @@ class TestStructures(unittest.TestCase): self.assertEqual(a, b) self.assertEqual(a, 1) self.assertGreater(a, 0) - self.assertLess(c, 1) + self.assertLess(c, 4) self.assertNotEqual(a, c) self.assertLess(a, c) self.assertGreaterEqual(a, b) -- GitLab