remove redundant comparisons/branches from _Inf

`__eq__` and `__ne__` can use the default `object.__eq__`/`object.__ne__`
This commit is contained in:
Thomas Grainger 2021-03-21 21:56:11 +00:00
parent 0d6cefdb16
commit deaf46cc62
No known key found for this signature in database
GPG Key ID: E452A1247BAC1A88
1 changed files with 4 additions and 28 deletions

View File

@ -74,41 +74,17 @@ class _Inf(object):
if sys.version_info >= (3, 0):
def __eq__(self, other): # type: (object) -> bool
c = self.__cmp__(other)
if c is NotImplemented:
return c # type: ignore[return-value]
return c == 0
def __ne__(self, other): # type: (object) -> bool
c = self.__cmp__(other)
if c is NotImplemented:
return c # type: ignore[return-value]
return c != 0
def __lt__(self, other): # type: (object) -> bool
c = self.__cmp__(other)
if c is NotImplemented:
return c # type: ignore[return-value]
return c < 0
return self.__cmp__(other) < 0
def __le__(self, other): # type: (object) -> bool
c = self.__cmp__(other)
if c is NotImplemented:
return c # type: ignore[return-value]
return c <= 0
return self.__cmp__(other) <= 0
def __gt__(self, other): # type: (object) -> bool
c = self.__cmp__(other)
if c is NotImplemented:
return c # type: ignore[return-value]
return c > 0
return self.__cmp__(other) > 0
def __ge__(self, other): # type: (object) -> bool
c = self.__cmp__(other)
if c is NotImplemented:
return c # type: ignore[return-value]
return c >= 0
return self.__cmp__(other) >= 0
_inf = _Inf()