Return NotImplemented sooner for ErrorDetail equality test (#7531)

The test suite raises warnings when tested against Python 3.9
`DeprecationWarning: NotImplemented should not be used in a boolean context`

Where `r` returns `NotImplemented` then this change returns `NotImplemented` first to avoid the comparison test.
This commit is contained in:
David Smith 2020-10-09 12:21:22 +01:00 committed by GitHub
parent 79daf315c4
commit 79c37d0dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,6 +73,8 @@ class ErrorDetail(str):
def __eq__(self, other): def __eq__(self, other):
r = super().__eq__(other) r = super().__eq__(other)
if r is NotImplemented:
return NotImplemented
try: try:
return r and self.code == other.code return r and self.code == other.code
except AttributeError: except AttributeError: