Remove extra parentheses (#4789)

This commit is contained in:
Artem Muterko 2017-01-08 18:09:23 +02:00 committed by Tom Christie
parent 44a99a11c3
commit 4dd71d68d2
6 changed files with 9 additions and 9 deletions

View File

@ -149,7 +149,7 @@ def to_choices_dict(choices):
# choices = [('Category', ((1, 'First'), (2, 'Second'))), (3, 'Third')]
ret = OrderedDict()
for choice in choices:
if (not isinstance(choice, (list, tuple))):
if not isinstance(choice, (list, tuple)):
# single choice
ret[choice] = choice
else:

View File

@ -131,7 +131,7 @@ def _reverse_ordering(ordering_tuple):
ordering and return a new tuple, eg. `('created', '-uuid')`.
"""
def invert(x):
return x[1:] if (x.startswith('-')) else '-' + x
return x[1:] if x.startswith('-') else '-' + x
return tuple([invert(item) for item in ordering_tuple])

View File

@ -503,7 +503,7 @@ class ManyRelatedField(Field):
return []
relationship = get_attribute(instance, self.source_attrs)
return relationship.all() if (hasattr(relationship, 'all')) else relationship
return relationship.all() if hasattr(relationship, 'all') else relationship
def to_representation(self, iterable):
return [

View File

@ -540,7 +540,7 @@ class BrowsableAPIRenderer(BaseRenderer):
# If possible, serialize the initial content for the generic form
default_parser = view.parser_classes[0]
renderer_class = getattr(default_parser, 'renderer_class', None)
if (hasattr(view, 'get_serializer') and renderer_class):
if hasattr(view, 'get_serializer') and renderer_class:
# View has a serializer defined and parser class has a
# corresponding renderer that can be used to render the data.
@ -598,7 +598,7 @@ class BrowsableAPIRenderer(BaseRenderer):
paginator = getattr(view, 'paginator', None)
if isinstance(data, list):
pass
elif (paginator is not None and data is not None):
elif paginator is not None and data is not None:
try:
paginator.get_results(data)
except (TypeError, KeyError):
@ -738,7 +738,7 @@ class AdminRenderer(BrowsableAPIRenderer):
ret = template_render(template, context, request=renderer_context['request'])
# Creation and deletion should use redirects in the admin style.
if (response.status_code == status.HTTP_201_CREATED) and ('Location' in response):
if response.status_code == status.HTTP_201_CREATED and 'Location' in response:
response.status_code = status.HTTP_303_SEE_OTHER
response['Location'] = request.build_absolute_uri()
ret = ''
@ -764,7 +764,7 @@ class AdminRenderer(BrowsableAPIRenderer):
)
paginator = getattr(context['view'], 'paginator', None)
if (paginator is not None and data is not None):
if paginator is not None and data is not None:
try:
results = paginator.get_results(data)
except (TypeError, KeyError):

View File

@ -152,7 +152,7 @@ class Request(object):
force_user = getattr(request, '_force_auth_user', None)
force_token = getattr(request, '_force_auth_token', None)
if (force_user is not None or force_token is not None):
if force_user is not None or force_token is not None:
forced_auth = ForcedAuthentication(force_user, force_token)
self.authenticators = (forced_auth,)

View File

@ -117,7 +117,7 @@ class NamespaceVersioning(BaseVersioning):
def determine_version(self, request, *args, **kwargs):
resolver_match = getattr(request, 'resolver_match', None)
if (resolver_match is None or not resolver_match.namespace):
if resolver_match is None or not resolver_match.namespace:
return self.default_version
# Allow for possibly nested namespaces.