diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 5dd6b35fe..7e4449deb 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -86,7 +86,6 @@ class ErrorDetail(str): def __repr__(self): return f"ErrorDetail(string='{str(self)}', code='{self.code}')" - def __hash__(self): return hash(str(self)) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 31fcf283f..d667a3826 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -236,9 +236,9 @@ class OrderingFilter(BaseFilterBackend): (field.source.replace('.', '__') or field_name, field.label) for field_name, field in serializer_class(context=context).fields.items() if ( - not getattr(field, 'write_only', False) and - not field.source == '*' and - field.source not in model_property_names + not getattr(field, 'write_only', False) and + not field.source == '*' and + field.source not in model_property_names ) ] diff --git a/rest_framework/relations.py b/rest_framework/relations.py index 3de6a6385..a80a51ee4 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -411,9 +411,9 @@ class HyperlinkedRelatedField(RelatedField): if value in ('', None): value_string = {'': 'the empty string', None: 'None'}[value] msg += ( - " WARNING: The value of the field on the model instance " - f"was {value_string}, which may be why it didn't match any " - "entries in your URL conf." + " WARNING: The value of the field on the model instance " + f"was {value_string}, which may be why it didn't match any " + "entries in your URL conf." ) raise ImproperlyConfigured(msg % self.view_name) diff --git a/rest_framework/request.py b/rest_framework/request.py index 324188396..0189f5c89 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -153,8 +153,7 @@ class Request: negotiator=None, parser_context=None): assert isinstance(request, HttpRequest), ( 'The `request` argument must be an instance of ' - '`django.http.HttpRequest`, not `{}.{}`.' - .format(request.__class__.__module__, request.__class__.__name__) + f'`django.http.HttpRequest`, not `{request.__class__.__module__}.{request.__class__.__name__}`.' # noqa ) self._request = request diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py index 0dbaa196e..8e35fec6e 100644 --- a/rest_framework/templatetags/rest_framework.py +++ b/rest_framework/templatetags/rest_framework.py @@ -219,7 +219,7 @@ def format_value(value): elif isinstance(value, str): if ( (value.startswith('http:') or value.startswith('https:')) and not - re.search(r'\s', value) + re.search(r'\s', value) ): return mark_safe('{value}'.format(value=escape(value))) elif '@' in value and not re.search(r'\s', value): diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 472e27e5f..3564a2698 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -70,9 +70,9 @@ class ErrorDetailTests(TestCase): def test_repr(self): assert repr(ErrorDetail('msg1')) == \ - f"ErrorDetail(string='msg1', code='None')" + "ErrorDetail(string='msg1', code='None')" assert repr(ErrorDetail('msg1', 'code')) == \ - f"ErrorDetail(string='msg1', code='code')" + "ErrorDetail(string='msg1', code='code')" def test_str(self): assert str(ErrorDetail('msg1')) == 'msg1'