From 8323177154c7996d72ac857f96ef59dd6206b66a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rajmund=20Hru=C5=A1ka?= <rajmund.hruska@gmail.com>
Date: Thu, 28 Nov 2024 14:41:19 +0100
Subject: [PATCH] Restrict objects for testing equality

---
 ipranges.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ipranges.py b/ipranges.py
index f4532b9..7224363 100644
--- a/ipranges.py
+++ b/ipranges.py
@@ -26,8 +26,15 @@ class Range(object):
         return self.high() - self.low() + 1
 
     def __eq__(self, other):
-        if isinstance(other, (IPRangeBase, IPNetBase, IPAddrBase)):
-            return (self.low() == other.low() and self.high() == other.high())
+        if (
+            hasattr(self, "single")
+            and hasattr(other, "single")
+            and (
+                issubclass(self.single, other.single)
+                or issubclass(self.single, other.single)
+            )
+        ):
+            return self.low() == other.low() and self.high() == other.high()
         return False
 
     def __ne__(self, other):
-- 
GitLab