Refactor short names in exceptions (#8585)

This commit is contained in:
Łukasz Wieczorek 2022-08-01 17:28:05 +02:00 committed by GitHub
parent 224168a28f
commit fd8adb32ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
"""
Handled exceptions raised by REST framework.
In addition Django's built in 403 and 404 exceptions are handled.
In addition, Django's built in 403 and 404 exceptions are handled.
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
"""
import math
@ -72,19 +72,19 @@ class ErrorDetail(str):
return self
def __eq__(self, other):
r = super().__eq__(other)
if r is NotImplemented:
result = super().__eq__(other)
if result is NotImplemented:
return NotImplemented
try:
return r and self.code == other.code
return result and self.code == other.code
except AttributeError:
return r
return result
def __ne__(self, other):
r = self.__eq__(other)
if r is NotImplemented:
result = self.__eq__(other)
if result is NotImplemented:
return NotImplemented
return not r
return not result
def __repr__(self):
return 'ErrorDetail(string=%r, code=%r)' % (