Skip to content
Snippets Groups Projects
Commit 83231771 authored by Rajmund Hruška's avatar Rajmund Hruška
Browse files

Restrict objects for testing equality

parent 7e4d41e8
No related branches found
No related tags found
1 merge request!9Add equality with arbitrary objects
Pipeline #12424 passed
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment