diff --git a/ipranges.py b/ipranges.py
index f4532b915ece22160d77f5f1f4816a1c18731353..722436352cb97ea96653944889d3f6a316d0c2ae 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):