Removed unnecessary parens in various code.

This commit is contained in:
Mariusz Felisiak 2017-09-14 03:20:29 +02:00 committed by Tim Graham
parent ee4043f735
commit 0ec0e5029c
8 changed files with 10 additions and 10 deletions

View File

@ -189,7 +189,7 @@ class UserSettingsHolder:
deleted = (setting in self._deleted)
set_locally = (setting in self.__dict__)
set_on_default = getattr(self.default_settings, 'is_overridden', lambda s: False)(setting)
return (deleted or set_locally or set_on_default)
return deleted or set_locally or set_on_default
def __repr__(self):
return '<%(cls)s>' % {

View File

@ -240,7 +240,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass):
if db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)):
elif db_field.name in list(self.filter_vertical) + list(self.filter_horizontal):
kwargs['widget'] = widgets.FilteredSelectMultiple(
db_field.verbose_name,
db_field.name in self.filter_vertical

View File

@ -61,7 +61,7 @@ def inject_rename_contenttypes_operations(plan=None, apps=global_apps, using=DEF
available = True
for migration, backward in plan:
if ((migration.app_label, migration.name) == ('contenttypes', '0001_initial')):
if (migration.app_label, migration.name) == ('contenttypes', '0001_initial'):
# There's no point in going forward if the initial contenttypes
# migration is unapplied as the ContentType model will be
# unavailable from this point.

View File

@ -106,8 +106,8 @@ else:
else:
def lock(f, flags):
ret = fcntl.flock(_fd(f), flags)
return (ret == 0)
return ret == 0
def unlock(f):
ret = fcntl.flock(_fd(f), fcntl.LOCK_UN)
return (ret == 0)
return ret == 0

View File

@ -54,7 +54,7 @@ if os.name == 'nt':
pass
try:
self.unlink(self.name)
except (OSError):
except OSError:
pass
def __del__(self):

View File

@ -173,7 +173,7 @@ class Command(BaseCommand):
progress_output = None
object_count = 0
# If dumpdata is outputting to stdout, there is no way to display progress
if (output and self.stdout.isatty() and options['verbosity'] > 0):
if output and self.stdout.isatty() and options['verbosity'] > 0:
progress_output = self.stdout
object_count = sum(get_objects(count_only=True))
stream = open(output, 'w') if output else None

View File

@ -1141,7 +1141,7 @@ class ModelChoiceIterator:
yield self.choice(obj)
def __len__(self):
return (len(self.queryset) + (1 if self.field.empty_label is not None else 0))
return len(self.queryset) + (1 if self.field.empty_label is not None else 0)
def choice(self, obj):
return (self.field.prepare_value(obj), self.field.label_from_instance(obj))

View File

@ -153,7 +153,7 @@ def get_conditional_response(request, etag=None, last_modified=None, response=No
if_modified_since = parse_http_date_safe(if_modified_since)
# Step 1 of section 6 of RFC 7232: Test the If-Match precondition.
if (if_match_etags and not _if_match_passes(etag, if_match_etags)):
if if_match_etags and not _if_match_passes(etag, if_match_etags):
return _precondition_failed(request)
# Step 2: Test the If-Unmodified-Since precondition.
@ -162,7 +162,7 @@ def get_conditional_response(request, etag=None, last_modified=None, response=No
return _precondition_failed(request)
# Step 3: Test the If-None-Match precondition.
if (if_none_match_etags and not _if_none_match_passes(etag, if_none_match_etags)):
if if_none_match_etags and not _if_none_match_passes(etag, if_none_match_etags):
if request.method in ('GET', 'HEAD'):
return _not_modified(request, response)
else: