#28769: Utilize 'x or y' in place of 'x if x else y'
------------------------------------------+------------------------
Reporter: Дилян Палаузов | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
{{{
diff --git a/django/contrib/admin/bin/compress.py
b/django/contrib/admin/bin/compress.py
--- a/django/contrib/admin/bin/compress.py
+++ b/django/contrib/admin/bin/compress.py
@@ -28,7 +28,7 @@ Compiler library and Java version 6 or later."""
parser.add_argument("-q", "--quiet", action="store_false",
dest="verbose")
options = parser.parse_args()
- compiler = Path(closure_compiler if closure_compiler else
options.compiler).expanduser()
+ compiler = Path(closure_compiler or options.compiler).expanduser()
if not compiler.exists():
sys.exit(
"Google Closure compiler jar file %s not found. Please use
the -c "
diff --git a/django/contrib/gis/gdal/raster/base.py
b/django/contrib/gis/gdal/raster/base.py
--- a/django/contrib/gis/gdal/raster/base.py
+++ b/django/contrib/gis/gdal/raster/base.py
@@ -56,7 +56,7 @@ class GDALRasterBase(GDALBase):
counter += 1
item = data[counter]
# The default domain values are returned if domain is None.
- result[domain if domain else 'DEFAULT'] = domain_meta
+ result[domain or 'DEFAULT'] = domain_meta
return result
@metadata.setter
diff --git a/django/core/management/commands/makemessages.py
b/django/core/management/commands/makemessages.py
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -323,9 +323,9 @@ class Command(BaseCommand):
raise CommandError("currently makemessages only supports
domains "
"'django' and 'djangojs'")
if self.domain == 'djangojs':
- exts = extensions if extensions else ['js']
+ exts = extensions or ['js']
else:
- exts = extensions if extensions else ['html', 'txt', 'py']
+ exts = extensions or ['html', 'txt', 'py']
self.extensions = handle_extensions(exts)
if (locale is None and not exclude and not process_all) or
self.domain is None:
diff --git a/django/db/backends/base/introspection.py
b/django/db/backends/base/introspection.py
--- a/django/db/backends/base/introspection.py
+++ b/django/db/backends/base/introspection.py
@@ -130,7 +130,7 @@ class BaseDatabaseIntrospection:
# we don't need to reset the sequence.
if f.remote_field.through is None:
sequence = self.get_sequences(cursor,
f.m2m_db_table())
- sequence_list.extend(sequence if sequence else
[{'table': f.m2m_db_table(), 'column': None}])
+ sequence_list.extend(sequence or [{'table':
f.m2m_db_table(), 'column': None}])
return sequence_list
def get_sequences(self, cursor, table_name, table_fields=()):
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -606,7 +606,7 @@ class Query:
# Ordering uses the 'rhs' ordering, unless it has none, in which
case
# the current ordering is used.
- self.order_by = rhs.order_by if rhs.order_by else self.order_by
+ self.order_by = rhs.order_by or self.order_by
self.extra_order_by = rhs.extra_order_by or self.extra_order_by
def deferred_to_data(self, target, callback):
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -474,7 +474,7 @@ class DateTimeBaseInput(TextInput):
def __init__(self, attrs=None, format=None):
super().__init__(attrs)
- self.format = format if format else None
+ self.format = format or None
def format_value(self, value):
return formats.localize_input(value, self.format or
formats.get_format(self.format_key)[0])
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28769>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/057.1cb218321b1ee424c14a6995f1e765bb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.