mirror of https://github.com/django/django.git
Removed unnecessary parens in various code.
This commit is contained in:
parent
ee4043f735
commit
0ec0e5029c
|
@ -189,7 +189,7 @@ class UserSettingsHolder:
|
||||||
deleted = (setting in self._deleted)
|
deleted = (setting in self._deleted)
|
||||||
set_locally = (setting in self.__dict__)
|
set_locally = (setting in self.__dict__)
|
||||||
set_on_default = getattr(self.default_settings, 'is_overridden', lambda s: False)(setting)
|
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):
|
def __repr__(self):
|
||||||
return '<%(cls)s>' % {
|
return '<%(cls)s>' % {
|
||||||
|
|
|
@ -240,7 +240,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass):
|
||||||
|
|
||||||
if db_field.name in self.raw_id_fields:
|
if db_field.name in self.raw_id_fields:
|
||||||
kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
|
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(
|
kwargs['widget'] = widgets.FilteredSelectMultiple(
|
||||||
db_field.verbose_name,
|
db_field.verbose_name,
|
||||||
db_field.name in self.filter_vertical
|
db_field.name in self.filter_vertical
|
||||||
|
|
|
@ -61,7 +61,7 @@ def inject_rename_contenttypes_operations(plan=None, apps=global_apps, using=DEF
|
||||||
available = True
|
available = True
|
||||||
|
|
||||||
for migration, backward in plan:
|
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
|
# There's no point in going forward if the initial contenttypes
|
||||||
# migration is unapplied as the ContentType model will be
|
# migration is unapplied as the ContentType model will be
|
||||||
# unavailable from this point.
|
# unavailable from this point.
|
||||||
|
|
|
@ -106,8 +106,8 @@ else:
|
||||||
else:
|
else:
|
||||||
def lock(f, flags):
|
def lock(f, flags):
|
||||||
ret = fcntl.flock(_fd(f), flags)
|
ret = fcntl.flock(_fd(f), flags)
|
||||||
return (ret == 0)
|
return ret == 0
|
||||||
|
|
||||||
def unlock(f):
|
def unlock(f):
|
||||||
ret = fcntl.flock(_fd(f), fcntl.LOCK_UN)
|
ret = fcntl.flock(_fd(f), fcntl.LOCK_UN)
|
||||||
return (ret == 0)
|
return ret == 0
|
||||||
|
|
|
@ -54,7 +54,7 @@ if os.name == 'nt':
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.unlink(self.name)
|
self.unlink(self.name)
|
||||||
except (OSError):
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
|
|
@ -173,7 +173,7 @@ class Command(BaseCommand):
|
||||||
progress_output = None
|
progress_output = None
|
||||||
object_count = 0
|
object_count = 0
|
||||||
# If dumpdata is outputting to stdout, there is no way to display progress
|
# 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
|
progress_output = self.stdout
|
||||||
object_count = sum(get_objects(count_only=True))
|
object_count = sum(get_objects(count_only=True))
|
||||||
stream = open(output, 'w') if output else None
|
stream = open(output, 'w') if output else None
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ class ModelChoiceIterator:
|
||||||
yield self.choice(obj)
|
yield self.choice(obj)
|
||||||
|
|
||||||
def __len__(self):
|
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):
|
def choice(self, obj):
|
||||||
return (self.field.prepare_value(obj), self.field.label_from_instance(obj))
|
return (self.field.prepare_value(obj), self.field.label_from_instance(obj))
|
||||||
|
|
|
@ -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)
|
if_modified_since = parse_http_date_safe(if_modified_since)
|
||||||
|
|
||||||
# Step 1 of section 6 of RFC 7232: Test the If-Match precondition.
|
# 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)
|
return _precondition_failed(request)
|
||||||
|
|
||||||
# Step 2: Test the If-Unmodified-Since precondition.
|
# 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)
|
return _precondition_failed(request)
|
||||||
|
|
||||||
# Step 3: Test the If-None-Match precondition.
|
# 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'):
|
if request.method in ('GET', 'HEAD'):
|
||||||
return _not_modified(request, response)
|
return _not_modified(request, response)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue