From c338f00ca0d4d6545df36507d7aff729a5057331 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Sat, 13 Feb 2021 16:17:41 +0100
Subject: [PATCH] improved `ComparableIntEnum`

---
 CHANGELOG.md                              |  1 +
 satella/__init__.py                       |  2 +-
 satella/coding/structures/mixins/enums.py | 14 ++++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e31010dd..2ad95b67 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
 # v2.14.36
 
 * fixed `AlreadySeen` to support non-hashable objects
+* improved `ComparableIntEnum`
diff --git a/satella/__init__.py b/satella/__init__.py
index 242a181a..041b19ad 100644
--- a/satella/__init__.py
+++ b/satella/__init__.py
@@ -1 +1 @@
-__version__ = '2.14.36a1'
+__version__ = '2.14.36a3'
diff --git a/satella/coding/structures/mixins/enums.py b/satella/coding/structures/mixins/enums.py
index 05d05d8e..39b76136 100644
--- a/satella/coding/structures/mixins/enums.py
+++ b/satella/coding/structures/mixins/enums.py
@@ -55,7 +55,9 @@ class HashableIntEnum(enum.IntEnum):
 class ComparableIntEnum(HashableIntEnum):
     """
     An enum.IntEnum that implements comparision, stemming from it's values, as well
-    as hashability
+    as hashability.
+
+    It it has an int() method, it's fair game as comparison argument for this class.
     """
 
     def __hash__(self) -> int:
@@ -64,24 +66,24 @@ class ComparableIntEnum(HashableIntEnum):
     def __lt__(self, other: 'ComparableIntEnum') -> bool:
         if isinstance(other, (int, float)):
             return self.value < other
-        return self.value < other.value
+        return self.value < int(other)
 
     def __le__(self, other: 'ComparableIntEnum') -> bool:
         if isinstance(other, (int, float)):
             return self.value <= other
-        return self.value <= other.value
+        return self.value <= int(other)
 
     def __gt__(self, other: 'ComparableIntEnum') -> bool:
         if isinstance(other, (int, float)):
             return self.value > other
-        return self.value > other.value
+        return self.value > int(other)
 
     def __ge__(self, other: 'ComparableIntEnum') -> bool:
         if isinstance(other, (int, float)):
             return self.value >= other
-        return self.value >= other.value
+        return self.value >= int(other)
 
     def __eq__(self, other: 'ComparableIntEnum') -> bool:
         if isinstance(other, (int, float)):
             return self.value == other
-        return self.value == other.value
+        return self.value == int(other)
-- 
GitLab