Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.1.0
hooks:
- id: black
exclude: \.py-tpl$
Expand All @@ -9,7 +9,7 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies:
- black==25.12.0
- black==26.1.0
files: 'docs/.*\.txt$'
args: ["--rst-literal-block"]
- repo: https://github.com/PyCQA/isort
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/gdal/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def expand_to_include(self, *args):
(args[0][0], args[0][1], args[0][0], args[0][1])
)
elif len(args[0]) == 4:
(minx, miny, maxx, maxy) = args[0]
minx, miny, maxx, maxy = args[0]
if minx < self._envelope.MinX:
self._envelope.MinX = minx
if miny < self._envelope.MinY:
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/mutable_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

Author: Aryeh Leib Taurog.
"""

from functools import total_ordering


Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
Inspired by GeoPy (https://github.com/geopy/geopy)
and Geoff Biggs' PhD work on dimensioned units for robotics.
"""

from decimal import Decimal
from functools import total_ordering

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/utils/layermapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information, please consult the GeoDjango documentation:
https://docs.djangoproject.com/en/dev/ref/contrib/gis/layermapping/
"""

import sys
from decimal import Decimal
from decimal import InvalidOperation as DecimalInvalidOperation
Expand Down
1 change: 0 additions & 1 deletion django/core/checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import django.core.checks.translation # NOQA isort:skip
import django.core.checks.urls # NOQA isort:skip


__all__ = [
"CheckMessage",
"Debug",
Expand Down
7 changes: 2 additions & 5 deletions django/core/management/commands/flush.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ def handle(self, **options):
)

if interactive:
confirm = input(
"""You have requested a flush of the database.
confirm = input("""You have requested a flush of the database.
This will IRREVERSIBLY DESTROY all data currently in the "%s" database,
and return each table to an empty state.
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: """
% connection.settings_dict["NAME"]
)
Type 'yes' to continue, or 'no' to cancel: """ % connection.settings_dict["NAME"])
else:
confirm = "yes"

Expand Down
6 changes: 2 additions & 4 deletions django/db/backends/mysql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,14 @@ def mysql_server_data(self):
# Select some server variables and test if the time zone
# definitions are installed. CONVERT_TZ returns NULL if 'UTC'
# timezone isn't loaded into the mysql.time_zone table.
cursor.execute(
"""
cursor.execute("""
SELECT VERSION(),
@@sql_mode,
@@default_storage_engine,
@@sql_auto_is_null,
@@lower_case_table_names,
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
"""
)
""")
row = cursor.fetchone()
return {
"version": row[0],
Expand Down
6 changes: 2 additions & 4 deletions django/db/backends/mysql/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,14 @@ def get_field_type(self, data_type, description):

def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
cursor.execute(
"""
cursor.execute("""
SELECT
table_name,
table_type,
table_comment
FROM information_schema.tables
WHERE table_schema = DATABASE()
"""
)
""")
return [
TableInfo(row[0], {"BASE TABLE": "t", "VIEW": "v"}.get(row[1]), row[2])
for row in cursor.fetchall()
Expand Down
6 changes: 2 additions & 4 deletions django/db/backends/oracle/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def get_field_type(self, data_type, description):

def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
cursor.execute(
"""
cursor.execute("""
SELECT
user_tables.table_name,
't',
Expand All @@ -79,8 +78,7 @@ def get_table_list(self, cursor):
SELECT view_name, 'v', NULL FROM user_views
UNION ALL
SELECT mview_name, 'v', NULL FROM user_mviews
"""
)
""")
return [
TableInfo(self.identifier_converter(row[0]), row[1], row[2])
for row in cursor.fetchall()
Expand Down
6 changes: 2 additions & 4 deletions django/db/backends/postgresql/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def get_field_type(self, data_type, description):

def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
cursor.execute(
"""
cursor.execute("""
SELECT
c.relname,
CASE
Expand All @@ -79,8 +78,7 @@ def get_table_list(self, cursor):
WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid)
"""
)
""")
return [
TableInfo(*row)
for row in cursor.fetchall()
Expand Down
6 changes: 2 additions & 4 deletions django/db/backends/sqlite3/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
# Skip the sqlite_sequence system table used for autoincrement key
# generation.
cursor.execute(
"""
cursor.execute("""
SELECT name, type FROM sqlite_master
WHERE type in ('table', 'view') AND NOT name='sqlite_sequence'
ORDER BY name"""
)
ORDER BY name""")
return [TableInfo(row[0], row[1][0]) for row in cursor.fetchall()]

def get_table_description(self, cursor, table_name):
Expand Down
1 change: 0 additions & 1 deletion django/db/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
OneToOneRel,
)


__all__ = aggregates_all + constraints_all + enums_all + fields_all + indexes_all
__all__ += [
"ObjectDoesNotExist",
Expand Down
1 change: 0 additions & 1 deletion django/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,4 @@
# Import the .autoreload module to trigger the registrations of signals.
from . import autoreload # NOQA isort:skip


__all__ += ("Template", "Context", "RequestContext")
24 changes: 6 additions & 18 deletions django/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ def _confirm_picklable(self, obj):
pickle.loads(pickle.dumps(obj))

def _print_unpicklable_subtest(self, test, subtest, pickle_exc):
print(
"""
print("""
Subtest failed:

test: {}
Expand All @@ -221,10 +220,7 @@ def _print_unpicklable_subtest(self, test, subtest, pickle_exc):

You should re-run this test with --parallel=1 to reproduce the failure
with a cleaner failure message.
""".format(
test, subtest, pickle_exc
)
)
""".format(test, subtest, pickle_exc))

def check_picklable(self, test, err):
# Ensure that sys.exc_info() tuples are picklable. This displays a
Expand All @@ -245,8 +241,7 @@ def check_picklable(self, test, err):
pickle_exc_txt, 75, initial_indent=" ", subsequent_indent=" "
)
if tblib is None:
print(
"""
print("""

{} failed:

Expand All @@ -258,13 +253,9 @@ def check_picklable(self, test, err):
In order to see the traceback, you should install tblib:

python -m pip install tblib
""".format(
test, original_exc_txt
)
)
""".format(test, original_exc_txt))
else:
print(
"""
print("""

{} failed:

Expand All @@ -279,10 +270,7 @@ def check_picklable(self, test, err):

You should re-run this test with the --parallel=1 option to reproduce the
failure and get a correct traceback.
""".format(
test, original_exc_txt, pickle_exc_txt
)
)
""".format(test, original_exc_txt, pickle_exc_txt))
raise

def check_subtest_picklable(self, test, subtest):
Expand Down
11 changes: 3 additions & 8 deletions docs/_ext/djangodocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ def run(self):
if len(self.arguments) > 1:
msg = """Only one argument accepted for directive '{directive_name}::'.
Comments should be provided as content,
not as an extra argument.""".format(
directive_name=self.name
)
not as an extra argument.""".format(directive_name=self.name)
raise self.error(msg)

env = self.state.document.settings.env
Expand Down Expand Up @@ -255,17 +253,14 @@ def visit_console_html(self, node):
# has been used on it.
self.document._console_directive_used_flag = True
uid = node["uid"]
self.body.append(
"""\
self.body.append("""\
<div class="console-block" id="console-block-%(id)s">
<input class="c-tab-unix" id="c-tab-%(id)s-unix" type="radio" name="console-%(id)s" \
checked>
<label for="c-tab-%(id)s-unix" title="Linux/macOS">&#xf17c/&#xf179</label>
<input class="c-tab-win" id="c-tab-%(id)s-win" type="radio" name="console-%(id)s">
<label for="c-tab-%(id)s-win" title="Windows">&#xf17a</label>
<section class="c-content-unix" id="c-content-%(id)s-unix">\n"""
% {"id": uid}
)
<section class="c-content-unix" id="c-content-%(id)s-unix">\n""" % {"id": uid})
try:
self.visit_literal_block(node)
except nodes.SkipNode:
Expand Down
1 change: 0 additions & 1 deletion docs/howto/custom-template-tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ implemented using a ``simple_block_tag`` as follows:
from django import template
from django.utils.html import format_html


register = template.Library()


Expand Down
6 changes: 2 additions & 4 deletions docs/ref/contrib/gis/gdal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1072,8 +1072,7 @@ Coordinate System Objects
>>> wgs84 = SpatialReference("EPSG:4326") # EPSG string
>>> proj = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs "
>>> wgs84 = SpatialReference(proj) # PROJ string
>>> wgs84 = SpatialReference(
... """GEOGCS["WGS 84",
>>> wgs84 = SpatialReference("""GEOGCS["WGS 84",
... DATUM["WGS_1984",
... SPHEROID["WGS 84",6378137,298.257223563,
... AUTHORITY["EPSG","7030"]],
Expand All @@ -1082,8 +1081,7 @@ Coordinate System Objects
... AUTHORITY["EPSG","8901"]],
... UNIT["degree",0.01745329251994328,
... AUTHORITY["EPSG","9122"]],
... AUTHORITY["EPSG","4326"]]"""
... ) # OGC WKT
... AUTHORITY["EPSG","4326"]]""") # OGC WKT

.. method:: __getitem__(target)

Expand Down
1 change: 0 additions & 1 deletion docs/ref/contrib/postgres/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ are ``Deferrable.DEFERRED`` or ``Deferrable.IMMEDIATE``. For example::
from django.contrib.postgres.fields import RangeOperators
from django.db.models import Deferrable


ExclusionConstraint(
name="exclude_overlapping_deferred",
expressions=[
Expand Down
7 changes: 3 additions & 4 deletions docs/topics/db/sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ had ``Person`` data in it, you could easily map it into ``Person`` instances:

.. code-block:: pycon

>>> Person.objects.raw(
... """
>>> Person.objects.raw("""
... SELECT first AS first_name,
... last AS last_name,
... bd AS birth_date,
... pk AS id,
... FROM some_other_table
... """
... )
... """)
...

As long as the names match, the model instances will be created correctly.

Expand Down
2 changes: 0 additions & 2 deletions docs/topics/tasks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ To receive the Task context as an argument to your Task function, pass
from django.core.mail import send_mail
from django.tasks import task


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -328,7 +327,6 @@ committed to the database, use :func:`transaction.on_commit()

from django.db import transaction


with transaction.atomic():
Thing.objects.create(num=1)
transaction.on_commit(partial(my_task.enqueue, thing_num=1))
Expand Down
10 changes: 5 additions & 5 deletions tests/auth_tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ def test_nonexistent_email(self):
self.assertEqual(len(mail.outbox), 0)

def test_cleaned_data(self):
(user, username, email) = self.create_dummy_user()
user, username, email = self.create_dummy_user()
data = {"email": email}
form = PasswordResetForm(data)
self.assertTrue(form.is_valid())
Expand Down Expand Up @@ -1303,7 +1303,7 @@ def test_inactive_user(self):
"""
Inactive user cannot receive password reset email.
"""
(user, username, email) = self.create_dummy_user()
user, username, email = self.create_dummy_user()
user.is_active = False
user.save()
form = PasswordResetForm({"email": email})
Expand All @@ -1330,7 +1330,7 @@ def test_save_plaintext_email(self):
html_email_template_name parameter passed in. Test to ensure original
behavior is unchanged after the parameter was added.
"""
(user, username, email) = self.create_dummy_user()
user, username, email = self.create_dummy_user()
form = PasswordResetForm({"email": email})
self.assertTrue(form.is_valid())
form.save()
Expand All @@ -1352,7 +1352,7 @@ def test_save_html_email_template_name(self):
Test to ensure that a multipart email is sent with both text/plain
and text/html parts.
"""
(user, username, email) = self.create_dummy_user()
user, username, email = self.create_dummy_user()
form = PasswordResetForm({"email": email})
self.assertTrue(form.is_valid())
form.save(
Expand Down Expand Up @@ -1382,7 +1382,7 @@ def test_save_html_email_template_name(self):

@override_settings(EMAIL_BACKEND="mail.custombackend.FailingEmailBackend")
def test_save_send_email_exceptions_are_catched_and_logged(self):
(user, username, email) = self.create_dummy_user()
user, username, email = self.create_dummy_user()
form = PasswordResetForm({"email": email})
self.assertTrue(form.is_valid())

Expand Down
Loading