exceptions.ErrorDetail: Handle NotImplemented correctly in __ne__ (#8538)

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-08-01 15:18:22 +01:00 committed by GitHub
parent a1b35bb44b
commit 224168a28f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,7 +81,10 @@ class ErrorDetail(str):
return r
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):
return 'ErrorDetail(string=%r, code=%r)' % (