summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2022-01-28 20:15:53 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-10-31 12:30:13 +0100
commitd3cb91db87b78629c0d2682630e90a048275179e (patch)
tree92476354cbb4df1bcff3cd1514a1bac6cbc98676 /django
parenta320aab5129f4019b3c1d28b7a3b509582bc56f9 (diff)
Used more augmented assignment statements.
Identified using the following command: $ git grep -I '\(\<[_a-zA-Z0-9]\+\>\) *= *\1 *[-+/*^%&|<>@]'
Diffstat (limited to 'django')
-rw-r--r--django/contrib/admin/helpers.py4
-rw-r--r--django/contrib/admin/options.py2
-rw-r--r--django/contrib/admin/static/admin/js/core.js4
-rw-r--r--django/contrib/auth/migrations/0011_update_proxy_permissions.py2
-rw-r--r--django/db/backends/base/schema.py2
-rw-r--r--django/db/backends/oracle/base.py6
-rw-r--r--django/db/backends/oracle/introspection.py2
-rw-r--r--django/db/backends/sqlite3/_functions.py4
-rw-r--r--django/db/models/fields/json.py10
-rw-r--r--django/db/models/fields/related.py2
-rw-r--r--django/db/models/sql/compiler.py2
-rw-r--r--django/db/models/sql/query.py2
-rw-r--r--django/forms/forms.py2
-rw-r--r--django/forms/models.py2
-rw-r--r--django/forms/widgets.py4
-rw-r--r--django/http/response.py2
-rw-r--r--django/middleware/security.py4
-rw-r--r--django/templatetags/i18n.py2
-rw-r--r--django/test/utils.py2
-rw-r--r--django/urls/base.py2
-rw-r--r--django/utils/datetime_safe.py4
-rw-r--r--django/utils/duration.py4
-rw-r--r--django/utils/numberformat.py2
-rw-r--r--django/utils/timezone.py2
-rw-r--r--django/utils/translation/__init__.py2
25 files changed, 38 insertions, 38 deletions
diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index 27b35f6ce8..b038b3ebbb 100644
--- a/django/contrib/admin/helpers.py
+++ b/django/contrib/admin/helpers.py
@@ -95,7 +95,7 @@ class AdminForm:
def media(self):
media = self.form.media
for fs in self:
- media = media + fs.media
+ media += fs.media
return media
@@ -456,7 +456,7 @@ class InlineAdminFormSet:
def media(self):
media = self.opts.media + self.formset.media
for fs in self:
- media = media + fs.media
+ media += fs.media
return media
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 215df9a059..e6d4ae12bb 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1840,7 +1840,7 @@ class ModelAdmin(BaseModelAdmin):
request, formsets, inline_instances, obj
)
for inline_formset in inline_formsets:
- media = media + inline_formset.media
+ media += inline_formset.media
if add:
title = _("Add %s")
diff --git a/django/contrib/admin/static/admin/js/core.js b/django/contrib/admin/static/admin/js/core.js
index afdae281c3..0344a13f42 100644
--- a/django/contrib/admin/static/admin/js/core.js
+++ b/django/contrib/admin/static/admin/js/core.js
@@ -119,11 +119,11 @@ function findPosY(obj) {
let result = '', i = 0;
while (i < format.length) {
if (format.charAt(i) === '%') {
- result = result + fields[format.charAt(i + 1)];
+ result += fields[format.charAt(i + 1)];
++i;
}
else {
- result = result + format.charAt(i);
+ result += format.charAt(i);
}
++i;
}
diff --git a/django/contrib/auth/migrations/0011_update_proxy_permissions.py b/django/contrib/auth/migrations/0011_update_proxy_permissions.py
index b792141d59..aa6ddd50c5 100644
--- a/django/contrib/auth/migrations/0011_update_proxy_permissions.py
+++ b/django/contrib/auth/migrations/0011_update_proxy_permissions.py
@@ -32,7 +32,7 @@ def update_proxy_model_permissions(apps, schema_editor, reverse=False):
]
permissions_query = Q(codename__in=proxy_default_permissions_codenames)
for codename, name in opts.permissions:
- permissions_query = permissions_query | Q(codename=codename, name=name)
+ permissions_query |= Q(codename=codename, name=name)
content_type_manager = ContentType.objects.db_manager(alias)
concrete_content_type = content_type_manager.get_for_model(
Model, for_concrete_model=True
diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
index bf2476a63e..fe31967ce2 100644
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -997,7 +997,7 @@ class BaseDatabaseSchemaEditor:
if not four_way_default_alteration:
# If we don't have to do a 4-way default alteration we can
# directly run a (NOT) NULL alteration
- actions = actions + null_actions
+ actions += null_actions
# Combine actions together if we can (e.g. postgres)
if self.connection.features.supports_combined_alters and actions:
sql, params = tuple(zip(*actions))
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 2ccd3bc028..29e43d1f62 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -528,7 +528,7 @@ class FormatStylePlaceholderCursor:
elif hasattr(params, "keys"):
# Handle params as dict
args = {k: ":%s" % k for k in params}
- query = query % args
+ query %= args
elif unify_by_values and params:
# Handle params as a dict with unified query parameters by their
# values. It can be used only in single query execute() because
@@ -542,11 +542,11 @@ class FormatStylePlaceholderCursor:
}
args = [params_dict[param] for param in params]
params = {value: key for key, value in params_dict.items()}
- query = query % tuple(args)
+ query %= tuple(args)
else:
# Handle params as sequence
args = [(":arg%d" % i) for i in range(len(params))]
- query = query % tuple(args)
+ query %= tuple(args)
return query, self._format_params(params)
def execute(self, query, params=None):
diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py
index ce743b291d..363b83efca 100644
--- a/django/db/backends/oracle/introspection.py
+++ b/django/db/backends/oracle/introspection.py
@@ -166,7 +166,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
for desc in cursor.description:
name = desc[0]
internal_size, default, collation, is_autofield, is_json = field_map[name]
- name = name % {} # cx_Oracle, for some reason, doubles percent signs.
+ name %= {} # cx_Oracle, for some reason, doubles percent signs.
description.append(
FieldInfo(
self.identifier_converter(name),
diff --git a/django/db/backends/sqlite3/_functions.py b/django/db/backends/sqlite3/_functions.py
index 49bd98cc5a..b590111ec5 100644
--- a/django/db/backends/sqlite3/_functions.py
+++ b/django/db/backends/sqlite3/_functions.py
@@ -134,7 +134,7 @@ def _sqlite_date_trunc(lookup_type, dt, tzname, conn_tzname):
elif lookup_type == "month":
return f"{dt.year:04d}-{dt.month:02d}-01"
elif lookup_type == "week":
- dt = dt - timedelta(days=dt.weekday())
+ dt -= timedelta(days=dt.weekday())
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d}"
elif lookup_type == "day":
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d}"
@@ -205,7 +205,7 @@ def _sqlite_datetime_trunc(lookup_type, dt, tzname, conn_tzname):
elif lookup_type == "month":
return f"{dt.year:04d}-{dt.month:02d}-01 00:00:00"
elif lookup_type == "week":
- dt = dt - timedelta(days=dt.weekday())
+ dt -= timedelta(days=dt.weekday())
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d} 00:00:00"
elif lookup_type == "day":
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d} 00:00:00"
diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py
index 7296fe42bc..22c7e2ad00 100644
--- a/django/db/models/fields/json.py
+++ b/django/db/models/fields/json.py
@@ -292,7 +292,7 @@ class JSONExact(lookups.Exact):
rhs_params = ["null"]
if connection.vendor == "mysql":
func = ["JSON_EXTRACT(%s, '$')"] * len(rhs_params)
- rhs = rhs % tuple(func)
+ rhs %= tuple(func)
return rhs, rhs_params
@@ -455,9 +455,9 @@ class KeyTransformIn(lookups.In):
value = json.loads(param)
sql = "%s(JSON_OBJECT('value' VALUE %%s FORMAT JSON), '$.value')"
if isinstance(value, (list, dict)):
- sql = sql % "JSON_QUERY"
+ sql %= "JSON_QUERY"
else:
- sql = sql % "JSON_VALUE"
+ sql %= "JSON_VALUE"
elif connection.vendor == "mysql" or (
connection.vendor == "sqlite"
and params[0] not in connection.ops.jsonfield_datatype_values
@@ -482,7 +482,7 @@ class KeyTransformExact(JSONExact):
func.append(sql % "JSON_QUERY")
else:
func.append(sql % "JSON_VALUE")
- rhs = rhs % tuple(func)
+ rhs %= tuple(func)
elif connection.vendor == "sqlite":
func = []
for value in rhs_params:
@@ -490,7 +490,7 @@ class KeyTransformExact(JSONExact):
func.append("%s")
else:
func.append("JSON_EXTRACT(%s, '$')")
- rhs = rhs % tuple(func)
+ rhs %= tuple(func)
return rhs, rhs_params
def as_oracle(self, compiler, connection):
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 63ed2ff4c7..c763f555e3 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -355,7 +355,7 @@ class RelatedField(FieldCacheMixin, Field):
else:
related_name = self.opts.default_related_name
if related_name:
- related_name = related_name % {
+ related_name %= {
"class": cls.__name__.lower(),
"model_name": cls._meta.model_name.lower(),
"app_label": cls._meta.app_label.lower(),
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 318e6b8707..f3b2b3da41 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -2046,7 +2046,7 @@ class SQLAggregateCompiler(SQLCompiler):
elide_empty=self.elide_empty,
).as_sql(with_col_aliases=True)
sql = "SELECT %s FROM (%s) subquery" % (sql, inner_query_sql)
- params = params + inner_query_params
+ params += inner_query_params
return sql, params
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index c2a71ff589..9735ce10c8 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1531,7 +1531,7 @@ class Query(BaseExpression):
):
"""Add a Q-object to the current filter."""
connector = q_object.connector
- current_negated = current_negated ^ q_object.negated
+ current_negated ^= q_object.negated
branch_negated = branch_negated or q_object.negated
target_clause = WhereNode(connector=connector, negated=q_object.negated)
joinpromoter = JoinPromoter(
diff --git a/django/forms/forms.py b/django/forms/forms.py
index 35471345c9..7c9f1034d2 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -492,7 +492,7 @@ class BaseForm(RenderableFormMixin):
"""Return all media required to render the widgets on this form."""
media = Media()
for field in self.fields.values():
- media = media + field.widget.media
+ media += field.widget.media
return media
def is_multipart(self):
diff --git a/django/forms/models.py b/django/forms/models.py
index 89cb000271..b79157ce68 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -316,7 +316,7 @@ class ModelFormMetaclass(DeclarativeFieldsMetaclass):
missing_fields = none_model_fields.difference(new_class.declared_fields)
if missing_fields:
message = "Unknown field(s) (%s) specified for %s"
- message = message % (", ".join(missing_fields), opts.model.__name__)
+ message %= (", ".join(missing_fields), opts.model.__name__)
raise FieldError(message)
# Override default model fields with any custom declared ones
# (plus, include all the other declared fields).
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 96cb910273..c5c531ada7 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -207,7 +207,7 @@ def media_property(cls):
else:
m = Media()
for medium in extend:
- m = m + base[medium]
+ m += base[medium]
return m + Media(definition)
return Media(definition)
return base
@@ -945,7 +945,7 @@ class MultiWidget(Widget):
"""
media = Media()
for w in self.widgets:
- media = media + w.media
+ media += w.media
return media
media = property(_get_media)
diff --git a/django/http/response.py b/django/http/response.py
index 7c0db55a5d..bb94e81263 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -241,7 +241,7 @@ class HttpResponseBase:
# Add one second so the date matches exactly (a fraction of
# time gets lost between converting to a timedelta and
# then the date string).
- delta = delta + datetime.timedelta(seconds=1)
+ delta += datetime.timedelta(seconds=1)
# Just set max_age - the max_age logic will set expires.
expires = None
if max_age is not None:
diff --git a/django/middleware/security.py b/django/middleware/security.py
index 1dd2204814..52c81e3406 100644
--- a/django/middleware/security.py
+++ b/django/middleware/security.py
@@ -38,9 +38,9 @@ class SecurityMiddleware(MiddlewareMixin):
):
sts_header = "max-age=%s" % self.sts_seconds
if self.sts_include_subdomains:
- sts_header = sts_header + "; includeSubDomains"
+ sts_header += "; includeSubDomains"
if self.sts_preload:
- sts_header = sts_header + "; preload"
+ sts_header += "; preload"
response.headers["Strict-Transport-Security"] = sts_header
if self.content_type_nosniff:
diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py
index 8b4824fbbf..b26cc701b4 100644
--- a/django/templatetags/i18n.py
+++ b/django/templatetags/i18n.py
@@ -187,7 +187,7 @@ class BlockTranslateNode(Node):
data = {v: render_value(v) for v in vars}
context.pop()
try:
- result = result % data
+ result %= data
except (KeyError, ValueError):
if nested:
# Either string is malformed, or it's a bug
diff --git a/django/test/utils.py b/django/test/utils.py
index 270e34b69d..2b2b92c593 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -593,7 +593,7 @@ class modify_settings(override_settings):
if isinstance(items, str):
items = [items]
if action == "append":
- value = value + [item for item in items if item not in value]
+ value += [item for item in items if item not in value]
elif action == "prepend":
value = [item for item in items if item not in value] + value
elif action == "remove":
diff --git a/django/urls/base.py b/django/urls/base.py
index 647ef3e2de..753779c75b 100644
--- a/django/urls/base.py
+++ b/django/urls/base.py
@@ -70,7 +70,7 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
try:
extra, resolver = resolver.namespace_dict[ns]
resolved_path.append(ns)
- ns_pattern = ns_pattern + extra
+ ns_pattern += extra
ns_converters.update(resolver.pattern.converters)
except KeyError as key:
if resolved_path:
diff --git a/django/utils/datetime_safe.py b/django/utils/datetime_safe.py
index 817ddcf0fa..2792b48a26 100644
--- a/django/utils/datetime_safe.py
+++ b/django/utils/datetime_safe.py
@@ -95,10 +95,10 @@ def strftime(dt, fmt):
# 6 years to get into the 28-year repeat cycle
delta = 2000 - year
off = 6 * (delta // 100 + delta // 400)
- year = year + off
+ year += off
# Move to around the year 2000
- year = year + ((2000 - year) // 28) * 28
+ year += ((2000 - year) // 28) * 28
timetuple = dt.timetuple()
s1 = time.strftime(fmt, (year,) + timetuple[1:])
sites1 = _findall(s1, str(year))
diff --git a/django/utils/duration.py b/django/utils/duration.py
index 8495af3fa8..eae8527710 100644
--- a/django/utils/duration.py
+++ b/django/utils/duration.py
@@ -7,10 +7,10 @@ def _get_duration_components(duration):
microseconds = duration.microseconds
minutes = seconds // 60
- seconds = seconds % 60
+ seconds %= 60
hours = minutes // 60
- minutes = minutes % 60
+ minutes %= 60
return days, hours, minutes, seconds, microseconds
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
index 6e3628ff91..a1ecd1bd0d 100644
--- a/django/utils/numberformat.py
+++ b/django/utils/numberformat.py
@@ -81,7 +81,7 @@ def format(
else:
int_part, dec_part = str_number, ""
if decimal_pos is not None:
- dec_part = dec_part + ("0" * (decimal_pos - len(dec_part)))
+ dec_part += "0" * (decimal_pos - len(dec_part))
dec_part = dec_part and decimal_sep + dec_part
# grouping
if use_grouping:
diff --git a/django/utils/timezone.py b/django/utils/timezone.py
index 2107ec96ae..f3eac0e7b2 100644
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -334,7 +334,7 @@ def _is_pytz_zone(tz):
_PYTZ_BASE_CLASSES = (pytz.tzinfo.BaseTzInfo, pytz._FixedOffset)
# In releases prior to 2018.4, pytz.UTC was not a subclass of BaseTzInfo
if not isinstance(pytz.UTC, pytz._FixedOffset):
- _PYTZ_BASE_CLASSES = _PYTZ_BASE_CLASSES + (type(pytz.UTC),)
+ _PYTZ_BASE_CLASSES += (type(pytz.UTC),)
return isinstance(tz, _PYTZ_BASE_CLASSES)
diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
index 6b8cc73d5c..0b3f78e486 100644
--- a/django/utils/translation/__init__.py
+++ b/django/utils/translation/__init__.py
@@ -149,7 +149,7 @@ def lazy_number(func, resultclass, number=None, **kwargs):
number_value = rhs
translated = self._translate(number_value)
try:
- translated = translated % rhs
+ translated %= rhs
except TypeError:
# String doesn't contain a placeholder for the number.
pass