diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index a48c31631..978576a71 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -80,8 +80,7 @@ class FormParser(BaseParser): """ parser_context = parser_context or {} encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET) - data = QueryDict(stream.read(), encoding=encoding) - return data + return QueryDict(stream.read(), encoding=encoding) class MultiPartParser(BaseParser): diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 623702966..143d1b7e7 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -674,7 +674,7 @@ class BrowsableAPIRenderer(BaseRenderer): csrf_header_name = csrf_header_name[5:] csrf_header_name = csrf_header_name.replace('_', '-') - context = { + return { 'content': self.get_content(renderer, data, accepted_media_type, renderer_context), 'code_style': pygments_css(self.code_style), 'view': view, @@ -710,7 +710,6 @@ class BrowsableAPIRenderer(BaseRenderer): 'csrf_cookie_name': csrf_cookie_name, 'csrf_header_name': csrf_header_name } - return context def render(self, data, accepted_media_type=None, renderer_context=None): """ diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index b8da446f7..66afcca94 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -184,9 +184,7 @@ class EndpointEnumerator: ) api_endpoints.extend(nested_endpoints) - api_endpoints = sorted(api_endpoints, key=endpoint_ordering) - - return api_endpoints + return sorted(api_endpoints, key=endpoint_ordering) def get_path_from_regex(self, path_regex): """ @@ -195,8 +193,7 @@ class EndpointEnumerator: path = simplify_regex(path_regex) # Strip Django 2.0 convertors as they are incompatible with uritemplate format - path = re.sub(_PATH_PARAMETER_COMPONENT_RE, r'{\g}', path) - return path + return re.sub(_PATH_PARAMETER_COMPONENT_RE, r'{\g}', path) def should_include_endpoint(self, path, callback): """ diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index 66f71a93e..2858c8c5b 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -435,8 +435,7 @@ class AutoSchema(ViewInspector): by_name = OrderedDict((f.name, f) for f in fields) for f in update_with: by_name[f.name] = f - fields = list(by_name.values()) - return fields + return list(by_name.values()) def get_encoding(self, path, method): """ diff --git a/rest_framework/utils/representation.py b/rest_framework/utils/representation.py index ebead5d75..3916eb686 100644 --- a/rest_framework/utils/representation.py +++ b/rest_framework/utils/representation.py @@ -41,9 +41,7 @@ def smart_repr(value): # # Should be presented as # - value = re.sub(' at 0x[0-9A-Fa-f]{4,32}>', '>', value) - - return value + return re.sub(' at 0x[0-9A-Fa-f]{4,32}>', '>', value) def field_repr(field, force_many=False): diff --git a/tests/test_renderers.py b/tests/test_renderers.py index 0a0271f45..d63dbcb9c 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -76,8 +76,7 @@ class MockView(APIView): renderer_classes = (RendererA, RendererB) def get(self, request, **kwargs): - response = Response(DUMMYCONTENT, status=DUMMYSTATUS) - return response + return Response(DUMMYCONTENT, status=DUMMYSTATUS) class MockGETView(APIView):