mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
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:
parent
79daf315c4
commit
79c37d0dc3
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user