Remove unnecessary assignments immediately before a return statement (#6619)

Cleans up the pattern:

    ...
    myvar = <expression>
    return myvar

To:

    ...
    return <expression>
This commit is contained in:
Jon Dufresne 2019-04-30 22:51:54 -07:00 committed by Carlton Gibson
parent 565794bedc
commit 5e1619bc9e
6 changed files with 7 additions and 16 deletions

View File

@ -80,8 +80,7 @@ class FormParser(BaseParser):
""" """
parser_context = parser_context or {} parser_context = parser_context or {}
encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET) encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
data = QueryDict(stream.read(), encoding=encoding) return QueryDict(stream.read(), encoding=encoding)
return data
class MultiPartParser(BaseParser): class MultiPartParser(BaseParser):

View File

@ -674,7 +674,7 @@ class BrowsableAPIRenderer(BaseRenderer):
csrf_header_name = csrf_header_name[5:] csrf_header_name = csrf_header_name[5:]
csrf_header_name = csrf_header_name.replace('_', '-') csrf_header_name = csrf_header_name.replace('_', '-')
context = { return {
'content': self.get_content(renderer, data, accepted_media_type, renderer_context), 'content': self.get_content(renderer, data, accepted_media_type, renderer_context),
'code_style': pygments_css(self.code_style), 'code_style': pygments_css(self.code_style),
'view': view, 'view': view,
@ -710,7 +710,6 @@ class BrowsableAPIRenderer(BaseRenderer):
'csrf_cookie_name': csrf_cookie_name, 'csrf_cookie_name': csrf_cookie_name,
'csrf_header_name': csrf_header_name 'csrf_header_name': csrf_header_name
} }
return context
def render(self, data, accepted_media_type=None, renderer_context=None): def render(self, data, accepted_media_type=None, renderer_context=None):
""" """

View File

@ -184,9 +184,7 @@ class EndpointEnumerator:
) )
api_endpoints.extend(nested_endpoints) api_endpoints.extend(nested_endpoints)
api_endpoints = sorted(api_endpoints, key=endpoint_ordering) return sorted(api_endpoints, key=endpoint_ordering)
return api_endpoints
def get_path_from_regex(self, path_regex): def get_path_from_regex(self, path_regex):
""" """
@ -195,8 +193,7 @@ class EndpointEnumerator:
path = simplify_regex(path_regex) path = simplify_regex(path_regex)
# Strip Django 2.0 convertors as they are incompatible with uritemplate format # Strip Django 2.0 convertors as they are incompatible with uritemplate format
path = re.sub(_PATH_PARAMETER_COMPONENT_RE, r'{\g<parameter>}', path) return re.sub(_PATH_PARAMETER_COMPONENT_RE, r'{\g<parameter>}', path)
return path
def should_include_endpoint(self, path, callback): def should_include_endpoint(self, path, callback):
""" """

View File

@ -435,8 +435,7 @@ class AutoSchema(ViewInspector):
by_name = OrderedDict((f.name, f) for f in fields) by_name = OrderedDict((f.name, f) for f in fields)
for f in update_with: for f in update_with:
by_name[f.name] = f by_name[f.name] = f
fields = list(by_name.values()) return list(by_name.values())
return fields
def get_encoding(self, path, method): def get_encoding(self, path, method):
""" """

View File

@ -41,9 +41,7 @@ def smart_repr(value):
# <django.core.validators.RegexValidator object at 0x1047af050> # <django.core.validators.RegexValidator object at 0x1047af050>
# Should be presented as # Should be presented as
# <django.core.validators.RegexValidator object> # <django.core.validators.RegexValidator object>
value = re.sub(' at 0x[0-9A-Fa-f]{4,32}>', '>', value) return re.sub(' at 0x[0-9A-Fa-f]{4,32}>', '>', value)
return value
def field_repr(field, force_many=False): def field_repr(field, force_many=False):

View File

@ -76,8 +76,7 @@ class MockView(APIView):
renderer_classes = (RendererA, RendererB) renderer_classes = (RendererA, RendererB)
def get(self, request, **kwargs): def get(self, request, **kwargs):
response = Response(DUMMYCONTENT, status=DUMMYSTATUS) return Response(DUMMYCONTENT, status=DUMMYSTATUS)
return response
class MockGETView(APIView): class MockGETView(APIView):