exceptions.ErrorDetail: Handle NotImplemented correctly in __ne__

PR #7531 resolved issue #7433 by updating `ErrorDetails.__eq__` to correctly
handle the `NotImplemented` case. However, Python 3.9 continues to issue the
following warning:

    DeprecationWarning: NotImplemented should not be used in a boolean context

This is because `__ne__` still doesn't handle the `NotImplemented` case
correctly. In order to avoid this warning, this commit makes the same change
for `__ne__` as previously made for `__eq__`.
This commit is contained in:
Allan Lewis 2022-06-29 10:32:49 +01:00
parent 101aff6c43
commit c59e8cc275
No known key found for this signature in database
GPG Key ID: 76E932831D293494

View File

@ -81,7 +81,10 @@ class ErrorDetail(str):
return r return r
def __ne__(self, other): def __ne__(self, other):
return not self.__eq__(other) r = self.__eq__(other)
if r is NotImplemented:
return NotImplemented
return not r
def __repr__(self): def __repr__(self):
return 'ErrorDetail(string=%r, code=%r)' % ( return 'ErrorDetail(string=%r, code=%r)' % (