Skip to content

Commit

Permalink
[4.1.x] Refs #33476 -- Applied Black's 2023 stable style.
Browse files Browse the repository at this point in the history
Black 23.1.0 is released which, as the first release of the year,
introduces the 2023 stable style. This incorporates most of last year's
preview style.

https://github.com/psf/black/releases/tag/23.1.0

Backport of 097e3a7 from main.
  • Loading branch information
smithdc1 authored and felixxm committed Feb 1, 2023
1 parent c629c78 commit a637d0b
Show file tree
Hide file tree
Showing 243 changed files with 62 additions and 288 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
exclude: \.py-tpl$
Expand Down
1 change: 0 additions & 1 deletion django/contrib/admin/migrations/0001_initial.py
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("contenttypes", "__first__"),
Expand Down
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [
("admin", "0001_initial"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("admin", "0002_logentry_remove_auto_add"),
]
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/admin/options.py
Expand Up @@ -980,7 +980,7 @@ def _get_base_actions(self):
base_action_names = {name for _, name, _ in base_actions}

# Gather actions from the admin site first
for (name, func) in self.admin_site.actions:
for name, func in self.admin_site.actions:
if name in base_action_names:
continue
description = self._get_action_description(func, name)
Expand Down Expand Up @@ -1104,6 +1104,7 @@ def get_search_results(self, request, queryset, search_term):
Return a tuple containing a queryset to implement the search
and a boolean indicating if the results may contain duplicates.
"""

# Apply keyword searches.
def construct_search(field_name):
if field_name.startswith("^"):
Expand Down
1 change: 0 additions & 1 deletion django/contrib/admin/tests.py
Expand Up @@ -17,7 +17,6 @@ def process_response(self, request, response):

@modify_settings(MIDDLEWARE={"append": "django.contrib.admin.tests.CSPMiddleware"})
class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):

available_apps = [
"django.contrib.admin",
"django.contrib.auth",
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admindocs/views.py
Expand Up @@ -148,7 +148,7 @@ def get_context_data(self, **kwargs):
view_functions = extract_views_from_urlpatterns(url_resolver.url_patterns)
except ImproperlyConfigured:
view_functions = []
for (func, regex, namespace, name) in view_functions:
for func, regex, namespace, name in view_functions:
views.append(
{
"full_name": get_view_name(func),
Expand Down
1 change: 0 additions & 1 deletion django/contrib/auth/migrations/0001_initial.py
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("contenttypes", "__first__"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0001_initial"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0002_alter_permission_name_max_length"),
]
Expand Down
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0003_alter_user_email_max_length"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0004_alter_user_username_opts"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0005_alter_user_last_login_null"),
("contenttypes", "0002_remove_content_type_name"),
Expand Down
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0006_require_contenttypes_0002"),
]
Expand Down
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0007_alter_validators_add_error_messages"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0008_alter_user_username_max_length"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0009_alter_user_last_name_max_length"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0011_update_proxy_permissions"),
]
Expand Down
1 change: 0 additions & 1 deletion django/contrib/contenttypes/migrations/0001_initial.py
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = []

operations = [
Expand Down
Expand Up @@ -13,7 +13,6 @@ def add_legacy_name(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
("contenttypes", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion django/contrib/flatpages/migrations/0001_initial.py
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("sites", "0001_initial"),
]
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/admin/widgets.py
Expand Up @@ -97,6 +97,7 @@ def get_context(self, name, value, attrs):

def map_options(self):
"""Build the map options hash for the OpenLayers template."""

# JavaScript construction utilities for the Bounds and Projection.
def ol_bounds(extent):
return "new OpenLayers.Bounds(%s)" % extent
Expand Down
1 change: 0 additions & 1 deletion django/contrib/gis/db/backends/oracle/operations.py
Expand Up @@ -54,7 +54,6 @@ def as_sql(self, connection, lookup, template_params, sql_params):


class OracleOperations(BaseSpatialOperations, DatabaseOperations):

name = "oracle"
oracle = True
disallowed_aggregates = (models.Collect, models.Extent3D, models.MakeLine)
Expand Down
1 change: 0 additions & 1 deletion django/contrib/gis/geos/geometry.py
Expand Up @@ -20,7 +20,6 @@


class GEOSGeometryBase(GEOSBase):

_GEOS_CLASSES = None

ptr_type = GEOM_PTR
Expand Down
1 change: 0 additions & 1 deletion django/contrib/redirects/migrations/0001_initial.py
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("sites", "0001_initial"),
]
Expand Down
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("redirects", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion django/contrib/sessions/migrations/0001_initial.py
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = []

operations = [
Expand Down
2 changes: 0 additions & 2 deletions django/contrib/sitemaps/views.py
Expand Up @@ -58,7 +58,6 @@ def index(
content_type="application/xml",
sitemap_url_name="django.contrib.sitemaps.views.sitemap",
):

req_protocol = request.scheme
req_site = get_current_site(request)

Expand Down Expand Up @@ -108,7 +107,6 @@ def sitemap(
template_name="sitemap.xml",
content_type="application/xml",
):

req_protocol = request.scheme
req_site = get_current_site(request)

Expand Down
1 change: 0 additions & 1 deletion django/contrib/sites/migrations/0001_initial.py
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = []

operations = [
Expand Down
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [
("sites", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion django/contrib/sites/models.py
Expand Up @@ -77,7 +77,6 @@ def get_by_natural_key(self, domain):


class Site(models.Model):

domain = models.CharField(
_("domain name"),
max_length=100,
Expand Down
1 change: 0 additions & 1 deletion django/core/cache/backends/db.py
Expand Up @@ -40,7 +40,6 @@ class CacheEntry:


class DatabaseCache(BaseDatabaseCache):

# This class uses cursors provided by the database connection. This means
# it reads expiration values as aware or naive datetimes, depending on the
# value of USE_TZ and whether the database supports time zones. The ORM's
Expand Down
2 changes: 1 addition & 1 deletion django/core/management/commands/dumpdata.py
Expand Up @@ -193,7 +193,7 @@ def get_objects(count_only=False):
# There is no need to sort dependencies when natural foreign
# keys are not used.
models = []
for (app_config, model_list) in app_list.items():
for app_config, model_list in app_list.items():
if model_list is None:
models.extend(app_config.get_models())
else:
Expand Down
1 change: 0 additions & 1 deletion django/core/management/commands/squashmigrations.py
Expand Up @@ -60,7 +60,6 @@ def add_arguments(self, parser):
)

def handle(self, **options):

self.verbosity = options["verbosity"]
self.interactive = options["interactive"]
app_label = options["app_label"]
Expand Down
1 change: 0 additions & 1 deletion django/core/management/templates.py
Expand Up @@ -150,7 +150,6 @@ def handle(self, app_or_project, name, target=None, **options):
prefix_length = len(template_dir) + 1

for root, dirs, files in os.walk(template_dir):

path_rest = root[prefix_length:]
relative_dir = path_rest.replace(base_name, name)
if relative_dir:
Expand Down
3 changes: 1 addition & 2 deletions django/core/serializers/python.py
Expand Up @@ -122,8 +122,7 @@ def Deserializer(
field_names = field_names_cache[Model]

# Handle each field
for (field_name, field_value) in d["fields"].items():

for field_name, field_value in d["fields"].items():
if ignorenonexistent and field_name not in field_names:
# skip fields no longer on model
continue
Expand Down
1 change: 1 addition & 0 deletions django/db/backends/base/creation.py
Expand Up @@ -116,6 +116,7 @@ def serialize_db_to_string(self):
Designed only for test runner usage; will not handle large
amounts of data.
"""

# Iteratively return every object for all models to serialize.
def get_objects():
from django.db.migrations.loader import MigrationLoader
Expand Down
1 change: 1 addition & 0 deletions django/db/backends/base/operations.py
Expand Up @@ -268,6 +268,7 @@ def last_executed_query(self, cursor, sql, params):
exists for database backends to provide a better implementation
according to their own quoting schemes.
"""

# Convert params to contain string values.
def to_string(s):
return force_str(s, strings_only=True, errors="replace")
Expand Down
1 change: 0 additions & 1 deletion django/db/backends/mysql/schema.py
Expand Up @@ -3,7 +3,6 @@


class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):

sql_rename_table = "RENAME TABLE %(old_table)s TO %(new_table)s"

sql_alter_column_null = "MODIFY %(column)s %(type)s NULL"
Expand Down
1 change: 0 additions & 1 deletion django/db/backends/oracle/schema.py
Expand Up @@ -11,7 +11,6 @@


class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):

sql_create_column = "ALTER TABLE %(table)s ADD %(column)s %(definition)s"
sql_alter_column_type = "MODIFY %(column)s %(type)s"
sql_alter_column_null = "MODIFY %(column)s NULL"
Expand Down
1 change: 0 additions & 1 deletion django/db/backends/postgresql/schema.py
Expand Up @@ -6,7 +6,6 @@


class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):

# Setting all constraints to IMMEDIATE to allow changing data in the same
# transaction.
sql_update_with_default = (
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/sqlite3/schema.py
Expand Up @@ -11,7 +11,6 @@


class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):

sql_delete_table = "DROP TABLE %(table)s"
sql_create_fk = None
sql_create_inline_fk = (
Expand Down Expand Up @@ -191,6 +190,7 @@ def _remake_table(
4. Rename the "new__app_model" table to "app_model"
5. Restore any index of the previous "app_model" table.
"""

# Self-referential fields must be recreated rather than copied from
# the old model to ensure their remote_field.field_name doesn't refer
# to an altered field.
Expand Down
1 change: 0 additions & 1 deletion django/db/backends/utils.py
Expand Up @@ -95,7 +95,6 @@ def _executemany(self, sql, param_list, *ignored_wrapper_args):


class CursorDebugWrapper(CursorWrapper):

# XXX callproc isn't instrumented at this time.

def execute(self, sql, params=None):
Expand Down
4 changes: 2 additions & 2 deletions django/db/migrations/operations/models.py
Expand Up @@ -400,7 +400,7 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state):
fields = zip(
old_model._meta.local_many_to_many, new_model._meta.local_many_to_many
)
for (old_field, new_field) in fields:
for old_field, new_field in fields:
# Skip self-referential fields as these are renamed above.
if (
new_field.model == new_field.related_model
Expand Down Expand Up @@ -505,7 +505,7 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state):
new_model._meta.db_table,
)
# Rename M2M fields whose name is based on this model's db_table
for (old_field, new_field) in zip(
for old_field, new_field in zip(
old_model._meta.local_many_to_many, new_model._meta.local_many_to_many
):
if new_field.remote_field.through._meta.auto_created:
Expand Down
1 change: 0 additions & 1 deletion django/db/models/expressions.py
Expand Up @@ -1089,7 +1089,6 @@ def as_sql(self, compiler, connection):


class Col(Expression):

contains_column_references = True
possibly_multivalued = False

Expand Down

0 comments on commit a637d0b

Please sign in to comment.