Applied Black's 2024 stable style.

https://github.com/psf/black/releases/tag/24.1.0
This commit is contained in:
Mariusz Felisiak 2024-01-26 12:45:07 +01:00 committed by GitHub
parent 3f6d939c62
commit 305757aec1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
235 changed files with 809 additions and 602 deletions

View File

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/psf/black-pre-commit-mirror - repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1 rev: 24.1.0
hooks: hooks:
- id: black - id: black
exclude: \.py-tpl$ exclude: \.py-tpl$
@ -9,7 +9,7 @@ repos:
hooks: hooks:
- id: blacken-docs - id: blacken-docs
additional_dependencies: additional_dependencies:
- black==23.12.1 - black==24.1.0
files: 'docs/.*\.txt$' files: 'docs/.*\.txt$'
- repo: https://github.com/PyCQA/isort - repo: https://github.com/PyCQA/isort
rev: 5.13.2 rev: 5.13.2

View File

@ -3,6 +3,7 @@ Invokes django-admin when the django module is run as a script.
Example: python -m django check Example: python -m django check
""" """
from django.core import management from django.core import management
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -5,6 +5,7 @@ Filters are specified in models with the "list_filter" option.
Each filter subclass knows how to display a filter for a field that passes a Each filter subclass knows how to display a filter for a field that passes a
certain test -- e.g. being a DateField or ForeignKey. certain test -- e.g. being a DateField or ForeignKey.
""" """
import datetime import datetime
from django.contrib.admin.exceptions import NotRegistered from django.contrib.admin.exceptions import NotRegistered

View File

@ -1759,9 +1759,9 @@ class ModelAdmin(BaseModelAdmin):
has_delete_permission = inline.has_delete_permission(request, obj) has_delete_permission = inline.has_delete_permission(request, obj)
else: else:
# Disable all edit-permissions, and override formset settings. # Disable all edit-permissions, and override formset settings.
has_add_permission = ( has_add_permission = has_change_permission = has_delete_permission = (
has_change_permission False
) = has_delete_permission = False )
formset.extra = formset.max_num = 0 formset.extra = formset.max_num = 0
has_view_permission = inline.has_view_permission(request, obj) has_view_permission = inline.has_view_permission(request, obj)
prepopulated = dict(inline.get_prepopulated_fields(request, obj)) prepopulated = dict(inline.get_prepopulated_fields(request, obj))
@ -1896,9 +1896,11 @@ class ModelAdmin(BaseModelAdmin):
form, form,
list(fieldsets), list(fieldsets),
# Clear prepopulated fields on a view-only form to avoid a crash. # Clear prepopulated fields on a view-only form to avoid a crash.
self.get_prepopulated_fields(request, obj) (
if add or self.has_change_permission(request, obj) self.get_prepopulated_fields(request, obj)
else {}, if add or self.has_change_permission(request, obj)
else {}
),
readonly_fields, readonly_fields,
model_admin=self, model_admin=self,
) )

View File

@ -171,9 +171,9 @@ def result_headers(cl):
"url_primary": cl.get_query_string({ORDER_VAR: ".".join(o_list_primary)}), "url_primary": cl.get_query_string({ORDER_VAR: ".".join(o_list_primary)}),
"url_remove": cl.get_query_string({ORDER_VAR: ".".join(o_list_remove)}), "url_remove": cl.get_query_string({ORDER_VAR: ".".join(o_list_remove)}),
"url_toggle": cl.get_query_string({ORDER_VAR: ".".join(o_list_toggle)}), "url_toggle": cl.get_query_string({ORDER_VAR: ".".join(o_list_toggle)}),
"class_attrib": format_html(' class="{}"', " ".join(th_classes)) "class_attrib": (
if th_classes format_html(' class="{}"', " ".join(th_classes)) if th_classes else ""
else "", ),
} }
@ -270,9 +270,11 @@ def items_for_result(cl, result, form):
link_or_text = format_html( link_or_text = format_html(
'<a href="{}"{}>{}</a>', '<a href="{}"{}>{}</a>',
url, url,
format_html(' data-popup-opener="{}"', value) (
if cl.is_popup format_html(' data-popup-opener="{}"', value)
else "", if cl.is_popup
else ""
),
result_repr, result_repr,
) )

View File

@ -1,6 +1,7 @@
""" """
Form Widget classes specific to the Django admin site. Form Widget classes specific to the Django admin site.
""" """
import copy import copy
import json import json

View File

@ -2,6 +2,7 @@
This module allows importing AbstractBaseUser even when django.contrib.auth is This module allows importing AbstractBaseUser even when django.contrib.auth is
not in INSTALLED_APPS. not in INSTALLED_APPS.
""" """
import unicodedata import unicodedata
from django.conf import settings from django.conf import settings

View File

@ -1,6 +1,7 @@
""" """
Creates permissions for all installed apps that need permissions. Creates permissions for all installed apps that need permissions.
""" """
import getpass import getpass
import unicodedata import unicodedata

View File

@ -1,6 +1,7 @@
""" """
Management utility to create superusers. Management utility to create superusers.
""" """
import getpass import getpass
import os import os
import sys import sys
@ -271,15 +272,19 @@ class Command(BaseCommand):
return "%s%s%s: " % ( return "%s%s%s: " % (
capfirst(field.verbose_name), capfirst(field.verbose_name),
" (leave blank to use '%s')" % default if default else "", " (leave blank to use '%s')" % default if default else "",
" (%s.%s)" (
% ( " (%s.%s)"
field.remote_field.model._meta.object_name, % (
field.m2m_target_field_name() field.remote_field.model._meta.object_name,
if field.many_to_many (
else field.remote_field.field_name, field.m2m_target_field_name()
) if field.many_to_many
if field.remote_field else field.remote_field.field_name
else "", ),
)
if field.remote_field
else ""
),
) )
@cached_property @cached_property

View File

@ -7,6 +7,7 @@
For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns
model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model. model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model.
""" """
from django.contrib.gis.db import models from django.contrib.gis.db import models
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin

View File

@ -7,6 +7,7 @@
support for an internal JVM, and Java libraries are required to use support for an internal JVM, and Java libraries are required to use
the WKT constructors. the WKT constructors.
""" """
import re import re
from django.contrib.gis.db import models from django.contrib.gis.db import models

View File

@ -1,6 +1,7 @@
""" """
This object provides quoting for GEOS geometries into PostgreSQL/PostGIS. This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
""" """
from django.contrib.gis.db.backends.postgis.pgraster import to_pgraster from django.contrib.gis.db.backends.postgis.pgraster import to_pgraster
from django.contrib.gis.geos import GEOSGeometry from django.contrib.gis.geos import GEOSGeometry
from django.db.backends.postgresql.psycopg_any import sql from django.db.backends.postgresql.psycopg_any import sql

View File

@ -1,6 +1,7 @@
""" """
PostGIS to GDAL conversion constant definitions PostGIS to GDAL conversion constant definitions
""" """
# Lookup to convert pixel type values from GDAL to PostGIS # Lookup to convert pixel type values from GDAL to PostGIS
GDAL_TO_POSTGIS = [None, 4, 6, 5, 8, 7, 10, 11, None, None, None, None] GDAL_TO_POSTGIS = [None, 4, 6, 5, 8, 7, 10, 11, None, None, None, None]

View File

@ -1,6 +1,7 @@
""" """
The GeometryColumns and SpatialRefSys models for the PostGIS backend. The GeometryColumns and SpatialRefSys models for the PostGIS backend.
""" """
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
from django.db import models from django.db import models

View File

@ -1,6 +1,7 @@
""" """
The GeometryColumns and SpatialRefSys models for the SpatiaLite backend. The GeometryColumns and SpatialRefSys models for the SpatiaLite backend.
""" """
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
from django.db import models from django.db import models

View File

@ -2,6 +2,7 @@
SQL functions reference lists: SQL functions reference lists:
https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html
""" """
from django.contrib.gis.db import models from django.contrib.gis.db import models
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter

View File

@ -127,9 +127,11 @@ class SQLiteDecimalToFloatMixin:
copy = self.copy() copy = self.copy()
copy.set_source_expressions( copy.set_source_expressions(
[ [
Value(float(expr.value)) (
if hasattr(expr, "value") and isinstance(expr.value, Decimal) Value(float(expr.value))
else expr if hasattr(expr, "value") and isinstance(expr.value, Decimal)
else expr
)
for expr in copy.get_source_expressions() for expr in copy.get_source_expressions()
] ]
) )
@ -349,9 +351,9 @@ class Distance(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
def as_sqlite(self, compiler, connection, **extra_context): def as_sqlite(self, compiler, connection, **extra_context):
if self.geo_field.geodetic(connection): if self.geo_field.geodetic(connection):
# SpatiaLite returns NULL instead of zero on geodetic coordinates # SpatiaLite returns NULL instead of zero on geodetic coordinates
extra_context[ extra_context["template"] = (
"template" "COALESCE(%(function)s(%(expressions)s, %(spheroid)s), 0)"
] = "COALESCE(%(function)s(%(expressions)s, %(spheroid)s), 0)" )
extra_context["spheroid"] = int(bool(self.spheroid)) extra_context["spheroid"] = int(bool(self.spheroid))
return super().as_sql(compiler, connection, **extra_context) return super().as_sql(compiler, connection, **extra_context)

View File

@ -5,6 +5,7 @@ objects corresponding to geographic model fields.
Thanks to Robert Coup for providing this functionality (see #4322). Thanks to Robert Coup for providing this functionality (see #4322).
""" """
from django.db.models.query_utils import DeferredAttribute from django.db.models.query_utils import DeferredAttribute

View File

@ -2,6 +2,7 @@
This module holds simple classes to convert geospatial values from the This module holds simple classes to convert geospatial values from the
database. database.
""" """
from decimal import Decimal from decimal import Decimal
from django.contrib.gis.measure import Area, Distance from django.contrib.gis.measure import Area, Distance

View File

@ -25,6 +25,7 @@
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
library on your system. library on your system.
""" """
from django.contrib.gis.gdal.datasource import DataSource from django.contrib.gis.gdal.datasource import DataSource
from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.driver import Driver
from django.contrib.gis.gdal.envelope import Envelope from django.contrib.gis.gdal.envelope import Envelope

View File

@ -33,6 +33,7 @@
# OFTReal returns floats, all else returns string. # OFTReal returns floats, all else returns string.
val = field.value val = field.value
""" """
from pathlib import Path from pathlib import Path
from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.base import GDALBase

View File

@ -10,6 +10,7 @@
| | | |
Lower left (min_x, min_y) o----------+ Lower left (min_x, min_y) o----------+
""" """
from ctypes import Structure, c_double from ctypes import Structure, c_double
from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.error import GDALException

View File

@ -38,6 +38,7 @@
>>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects >>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
True True True True
""" """
import sys import sys
import warnings import warnings
from binascii import b2a_hex from binascii import b2a_hex

View File

@ -3,6 +3,7 @@
related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*, related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*,
OGR_Fld_* routines are relevant here. OGR_Fld_* routines are relevant here.
""" """
from ctypes import POINTER, c_char_p, c_double, c_int, c_long, c_uint, c_void_p from ctypes import POINTER, c_char_p, c_double, c_int, c_long, c_uint, c_void_p
from django.contrib.gis.gdal.envelope import OGREnvelope from django.contrib.gis.gdal.envelope import OGREnvelope

View File

@ -2,6 +2,7 @@
This module houses the error-checking routines used by the GDAL This module houses the error-checking routines used by the GDAL
ctypes prototypes. ctypes prototypes.
""" """
from ctypes import c_void_p, string_at from ctypes import c_void_p, string_at
from django.contrib.gis.gdal.error import GDALException, SRSException, check_err from django.contrib.gis.gdal.error import GDALException, SRSException, check_err

View File

@ -2,6 +2,7 @@
This module contains functions that generate ctypes prototypes for the This module contains functions that generate ctypes prototypes for the
GDAL routines. GDAL routines.
""" """
from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_int64, c_void_p from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_int64, c_void_p
from functools import partial from functools import partial

View File

@ -2,6 +2,7 @@
This module houses the ctypes function prototypes for GDAL DataSource (raster) This module houses the ctypes function prototypes for GDAL DataSource (raster)
related data structures. related data structures.
""" """
from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_void_p from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_void_p
from functools import partial from functools import partial

View File

@ -1,6 +1,7 @@
""" """
GDAL - Constant definitions GDAL - Constant definitions
""" """
from ctypes import ( from ctypes import (
c_double, c_double,
c_float, c_float,

View File

@ -26,6 +26,7 @@
>>> print(srs.name) >>> print(srs.name)
NAD83 / Texas South Central NAD83 / Texas South Central
""" """
from ctypes import byref, c_char_p, c_int from ctypes import byref, c_char_p, c_int
from enum import IntEnum from enum import IntEnum
from types import NoneType from types import NoneType

View File

@ -2,6 +2,7 @@
The GeoDjango GEOS module. Please consult the GeoDjango documentation The GeoDjango GEOS module. Please consult the GeoDjango documentation
for more details: https://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/ for more details: https://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
""" """
from .collections import ( # NOQA from .collections import ( # NOQA
GeometryCollection, GeometryCollection,
MultiLineString, MultiLineString,

View File

@ -2,6 +2,7 @@
This module houses the Geometry Collection objects: This module houses the Geometry Collection objects:
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
""" """
from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin
from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.libgeos import GEOM_PTR

View File

@ -3,6 +3,7 @@
by GEOSGeometry to house the actual coordinates of the Point, by GEOSGeometry to house the actual coordinates of the Point,
LineString, and LinearRing geometries. LineString, and LinearRing geometries.
""" """
from ctypes import byref, c_byte, c_double, c_uint from ctypes import byref, c_byte, c_double, c_uint
from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos import prototypes as capi

View File

@ -2,6 +2,7 @@
This module contains the 'base' GEOSGeometry object -- all GEOS Geometries This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
inherit from this object. inherit from this object.
""" """
import re import re
from ctypes import addressof, byref, c_double from ctypes import addressof, byref, c_double

View File

@ -3,6 +3,7 @@ Module that holds classes for performing I/O operations on GEOS geometry
objects. Specifically, this has Python implementations of WKB/WKT objects. Specifically, this has Python implementations of WKB/WKT
reader and writer classes. reader and writer classes.
""" """
from django.contrib.gis.geos.geometry import GEOSGeometry from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.prototypes.io import ( from django.contrib.gis.geos.prototypes.io import (
WKBWriter, WKBWriter,

View File

@ -6,6 +6,7 @@
This module also houses GEOS Pointer utilities, including This module also houses GEOS Pointer utilities, including
get_pointer_arr(), and GEOM_PTR. get_pointer_arr(), and GEOM_PTR.
""" """
import logging import logging
import os import os
from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_char_p from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_char_p

View File

@ -1,6 +1,7 @@
""" """
Error checking functions for GEOS ctypes prototype functions. Error checking functions for GEOS ctypes prototype functions.
""" """
from ctypes import c_void_p, string_at from ctypes import c_void_p, string_at
from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.error import GEOSException

View File

@ -2,6 +2,7 @@
This module is for the miscellaneous GEOS routines, particularly the This module is for the miscellaneous GEOS routines, particularly the
ones that return the area, distance, and length. ones that return the area, distance, and length.
""" """
from ctypes import POINTER, c_double, c_int from ctypes import POINTER, c_double, c_int
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory

View File

@ -2,6 +2,7 @@
This module houses the GEOS ctypes prototype functions for the This module houses the GEOS ctypes prototype functions for the
unary and binary predicate operations on geometries. unary and binary predicate operations on geometries.
""" """
from ctypes import c_byte, c_char_p, c_double from ctypes import c_byte, c_char_p, c_double
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory

View File

@ -2,6 +2,7 @@
This module houses the GEOS ctypes prototype functions for the This module houses the GEOS ctypes prototype functions for the
topological operations on geometries. topological operations on geometries.
""" """
from ctypes import c_double, c_int from ctypes import c_double, c_int
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory

View File

@ -1,6 +1,7 @@
""" """
This module contains useful utilities for GeoDjango. This module contains useful utilities for GeoDjango.
""" """
from django.contrib.gis.utils.ogrinfo import ogrinfo from django.contrib.gis.utils.ogrinfo import ogrinfo
from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect
from django.contrib.gis.utils.srs import add_srs_entry from django.contrib.gis.utils.srs import add_srs_entry

View File

@ -3,6 +3,7 @@ This module is for inspecting OGR data sources and generating either
models for GeoDjango and/or mapping dictionaries for use with the models for GeoDjango and/or mapping dictionaries for use with the
`LayerMapping` utility. `LayerMapping` utility.
""" """
from django.contrib.gis.gdal import DataSource from django.contrib.gis.gdal import DataSource
from django.contrib.gis.gdal.field import ( from django.contrib.gis.gdal.field import (
OFTDate, OFTDate,

View File

@ -116,9 +116,11 @@ class SearchVector(SearchVectorCombinable, Func):
clone.set_source_expressions( clone.set_source_expressions(
[ [
Coalesce( Coalesce(
expression (
if isinstance(expression.output_field, (CharField, TextField)) expression
else Cast(expression, TextField()), if isinstance(expression.output_field, (CharField, TextField))
else Cast(expression, TextField())
),
Value(""), Value(""),
) )
for expression in clone.get_source_expressions() for expression in clone.get_source_expressions()

View File

@ -2,6 +2,7 @@
This module allows importing AbstractBaseSession even This module allows importing AbstractBaseSession even
when django.contrib.sessions is not in INSTALLED_APPS. when django.contrib.sessions is not in INSTALLED_APPS.
""" """
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _

View File

@ -3,6 +3,7 @@ Views and functions for serving static files. These are only to be used during
development, and SHOULD NOT be used in a production setting. development, and SHOULD NOT be used in a production setting.
""" """
import os import os
import posixpath import posixpath

View File

@ -12,6 +12,7 @@ object.
See docs/topics/cache.txt for information on the public API. See docs/topics/cache.txt for information on the public API.
""" """
from django.core import signals from django.core import signals
from django.core.cache.backends.base import ( from django.core.cache.backends.base import (
BaseCache, BaseCache,

View File

@ -1,6 +1,7 @@
""" """
Global Django exception and warning classes. Global Django exception and warning classes.
""" """
import operator import operator
from django.utils.hashable import make_hashable from django.utils.hashable import make_hashable

View File

@ -3,6 +3,7 @@ Utility functions for handling images.
Requires Pillow as you might imagine. Requires Pillow as you might imagine.
""" """
import struct import struct
import zlib import zlib

View File

@ -16,6 +16,7 @@ Example Usage::
... locks.lock(f, locks.LOCK_EX) ... locks.lock(f, locks.LOCK_EX)
... f.write('Django') ... f.write('Django')
""" """
import os import os
__all__ = ("LOCK_EX", "LOCK_SH", "LOCK_NB", "lock", "unlock") __all__ = ("LOCK_EX", "LOCK_SH", "LOCK_NB", "lock", "unlock")

View File

@ -1,6 +1,7 @@
""" """
Base file upload handler classes, and the built-in concrete subclasses Base file upload handler classes, and the built-in concrete subclasses
""" """
import os import os
from io import BytesIO from io import BytesIO

View File

@ -1,6 +1,7 @@
""" """
Tools for sending email. Tools for sending email.
""" """
from django.conf import settings from django.conf import settings
# Imported for backwards compatibility and for the sake # Imported for backwards compatibility and for the sake

View File

@ -1,6 +1,7 @@
""" """
Email backend that writes messages to console instead of sending them. Email backend that writes messages to console instead of sending them.
""" """
import sys import sys
import threading import threading

View File

@ -1,6 +1,7 @@
""" """
Backend for test environment. Backend for test environment.
""" """
import copy import copy
from django.core import mail from django.core import mail

View File

@ -1,4 +1,5 @@
"""SMTP email backend class.""" """SMTP email backend class."""
import smtplib import smtplib
import ssl import ssl
import threading import threading

View File

@ -2,6 +2,7 @@
Base classes for writing management commands (named commands which can Base classes for writing management commands (named commands which can
be executed through ``django-admin`` or ``manage.py``). be executed through ``django-admin`` or ``manage.py``).
""" """
import argparse import argparse
import os import os
import sys import sys
@ -528,9 +529,11 @@ class BaseCommand:
if issues: if issues:
visible_issue_count += len(issues) visible_issue_count += len(issues)
formatted = ( formatted = (
self.style.ERROR(str(e)) (
if e.is_serious() self.style.ERROR(str(e))
else self.style.WARNING(str(e)) if e.is_serious()
else self.style.WARNING(str(e))
)
for e in issues for e in issues
) )
formatted = "\n".join(sorted(formatted)) formatted = "\n".join(sorted(formatted))
@ -543,11 +546,15 @@ class BaseCommand:
if visible_issue_count: if visible_issue_count:
footer += "\n" footer += "\n"
footer += "System check identified %s (%s silenced)." % ( footer += "System check identified %s (%s silenced)." % (
"no issues" (
if visible_issue_count == 0 "no issues"
else "1 issue" if visible_issue_count == 0
if visible_issue_count == 1 else (
else "%s issues" % visible_issue_count, "1 issue"
if visible_issue_count == 1
else "%s issues" % visible_issue_count
)
),
len(all_issues) - visible_issue_count, len(all_issues) - visible_issue_count,
) )

View File

@ -1,6 +1,7 @@
""" """
Module for abstract serializer/unserializer base classes. Module for abstract serializer/unserializer base classes.
""" """
from io import StringIO from io import StringIO
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist

View File

@ -1,6 +1,7 @@
""" """
XML serializer. XML serializer.
""" """
import json import json
from xml.dom import pulldom from xml.dom import pulldom
from xml.sax import handler from xml.sax import handler

View File

@ -724,9 +724,9 @@ class BaseDatabaseSchemaEditor:
namespace, _ = split_identifier(model._meta.db_table) namespace, _ = split_identifier(model._meta.db_table)
definition += " " + self.sql_create_column_inline_fk % { definition += " " + self.sql_create_column_inline_fk % {
"name": self._fk_constraint_name(model, field, constraint_suffix), "name": self._fk_constraint_name(model, field, constraint_suffix),
"namespace": "%s." % self.quote_name(namespace) "namespace": (
if namespace "%s." % self.quote_name(namespace) if namespace else ""
else "", ),
"column": self.quote_name(field.column), "column": self.quote_name(field.column),
"to_table": self.quote_name(to_table), "to_table": self.quote_name(to_table),
"to_column": self.quote_name(to_column), "to_column": self.quote_name(to_column),
@ -1919,11 +1919,13 @@ class BaseDatabaseSchemaEditor:
"""Return all constraint names matching the columns and conditions.""" """Return all constraint names matching the columns and conditions."""
if column_names is not None: if column_names is not None:
column_names = [ column_names = [
self.connection.introspection.identifier_converter( (
truncate_name(name, self.connection.ops.max_name_length()) self.connection.introspection.identifier_converter(
truncate_name(name, self.connection.ops.max_name_length())
)
if self.connection.features.truncates_names
else self.connection.introspection.identifier_converter(name)
) )
if self.connection.features.truncates_names
else self.connection.introspection.identifier_converter(name)
for name in column_names for name in column_names
] ]
with self.connection.cursor() as cursor: with self.connection.cursor() as cursor:

View File

@ -2,6 +2,7 @@
Helpers to manipulate deferred DDL statements that might need to be adjusted or Helpers to manipulate deferred DDL statements that might need to be adjusted or
discarded within when executing a migration. discarded within when executing a migration.
""" """
from copy import deepcopy from copy import deepcopy

View File

@ -3,6 +3,7 @@ MySQL database backend for Django.
Requires mysqlclient: https://pypi.org/project/mysqlclient/ Requires mysqlclient: https://pypi.org/project/mysqlclient/
""" """
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.db import IntegrityError from django.db import IntegrityError
from django.db.backends import utils as backend_utils from django.db.backends import utils as backend_utils

View File

@ -3,6 +3,7 @@ Oracle database backend for Django.
Requires oracledb: https://oracle.github.io/python-oracledb/ Requires oracledb: https://oracle.github.io/python-oracledb/
""" """
import datetime import datetime
import decimal import decimal
import os import os

View File

@ -133,20 +133,20 @@ class DatabaseCreation(BaseDatabaseCreation):
credentials in the SAVED_USER/SAVED_PASSWORD key in the settings dict. credentials in the SAVED_USER/SAVED_PASSWORD key in the settings dict.
""" """
real_settings = settings.DATABASES[self.connection.alias] real_settings = settings.DATABASES[self.connection.alias]
real_settings["SAVED_USER"] = self.connection.settings_dict[ real_settings["SAVED_USER"] = self.connection.settings_dict["SAVED_USER"] = (
"SAVED_USER" self.connection.settings_dict["USER"]
] = self.connection.settings_dict["USER"] )
real_settings["SAVED_PASSWORD"] = self.connection.settings_dict[ real_settings["SAVED_PASSWORD"] = self.connection.settings_dict[
"SAVED_PASSWORD" "SAVED_PASSWORD"
] = self.connection.settings_dict["PASSWORD"] ] = self.connection.settings_dict["PASSWORD"]
real_test_settings = real_settings["TEST"] real_test_settings = real_settings["TEST"]
test_settings = self.connection.settings_dict["TEST"] test_settings = self.connection.settings_dict["TEST"]
real_test_settings["USER"] = real_settings["USER"] = test_settings[ real_test_settings["USER"] = real_settings["USER"] = test_settings["USER"] = (
"USER" self.connection.settings_dict["USER"]
] = self.connection.settings_dict["USER"] = parameters["user"] ) = parameters["user"]
real_settings["PASSWORD"] = self.connection.settings_dict[ real_settings["PASSWORD"] = self.connection.settings_dict["PASSWORD"] = (
"PASSWORD" parameters["password"]
] = parameters["password"] )
def set_as_test_mirror(self, primary_settings_dict): def set_as_test_mirror(self, primary_settings_dict):
""" """

View File

@ -226,9 +226,11 @@ class DatabaseWrapper(BaseDatabaseWrapper):
server_side_binding = conn_params.pop("server_side_binding", None) server_side_binding = conn_params.pop("server_side_binding", None)
conn_params.setdefault( conn_params.setdefault(
"cursor_factory", "cursor_factory",
ServerBindingCursor (
if is_psycopg3 and server_side_binding is True ServerBindingCursor
else Cursor, if is_psycopg3 and server_side_binding is True
else Cursor
),
) )
if settings_dict["USER"]: if settings_dict["USER"]:
conn_params["user"] = settings_dict["USER"] conn_params["user"] = settings_dict["USER"]

View File

@ -267,9 +267,9 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
% { % {
"column": self.quote_name(new_field.column), "column": self.quote_name(new_field.column),
"type": new_type, "type": new_type,
"collation": " " + self._collate_sql(new_collation) "collation": (
if new_collation " " + self._collate_sql(new_collation) if new_collation else ""
else "", ),
}, },
[], [],
) )

View File

@ -1,6 +1,7 @@
""" """
Implementations of SQL functions for SQLite. Implementations of SQL functions for SQLite.
""" """
import functools import functools
import random import random
import statistics import statistics

View File

@ -1,6 +1,7 @@
""" """
SQLite backend for the sqlite3 module in the standard library. SQLite backend for the sqlite3 module in the standard library.
""" """
import datetime import datetime
import decimal import decimal
import warnings import warnings

View File

@ -620,11 +620,12 @@ class MigrationAutodetector:
rem_model_state.app_label, rem_model_state.app_label,
rem_model_state.name_lower, rem_model_state.name_lower,
) )
self.renamed_models_rel[ self.renamed_models_rel[renamed_models_rel_key] = (
renamed_models_rel_key "%s.%s"
] = "%s.%s" % ( % (
model_state.app_label, model_state.app_label,
model_state.name_lower, model_state.name_lower,
)
) )
self.old_model_keys.remove((rem_app_label, rem_model_name)) self.old_model_keys.remove((rem_app_label, rem_model_name))
self.old_model_keys.add((app_label, model_name)) self.old_model_keys.add((app_label, model_name))
@ -1058,9 +1059,9 @@ class MigrationAutodetector:
(rem_app_label, rem_model_name, rem_field_name) (rem_app_label, rem_model_name, rem_field_name)
) )
old_field_keys.add((app_label, model_name, field_name)) old_field_keys.add((app_label, model_name, field_name))
self.renamed_fields[ self.renamed_fields[app_label, model_name, field_name] = (
app_label, model_name, field_name rem_field_name
] = rem_field_name )
break break
def generate_renamed_fields(self): def generate_renamed_fields(self):

View File

@ -131,11 +131,11 @@ class MigrationLoader:
"Migration %s in app %s has no Migration class" "Migration %s in app %s has no Migration class"
% (migration_name, app_config.label) % (migration_name, app_config.label)
) )
self.disk_migrations[ self.disk_migrations[app_config.label, migration_name] = (
app_config.label, migration_name migration_module.Migration(
] = migration_module.Migration( migration_name,
migration_name, app_config.label,
app_config.label, )
) )
def get_migration(self, app_label, name_prefix): def get_migration(self, app_label, name_prefix):

View File

@ -56,11 +56,11 @@ class CreateModel(ModelOperation):
_check_for_duplicates( _check_for_duplicates(
"bases", "bases",
( (
base._meta.label_lower (
if hasattr(base, "_meta") base._meta.label_lower
else base.lower() if hasattr(base, "_meta")
if isinstance(base, str) else base.lower() if isinstance(base, str) else base
else base )
for base in self.bases for base in self.bases
), ),
) )

View File

@ -524,11 +524,11 @@ class ProjectState:
if model_state.options.get("proxy"): if model_state.options.get("proxy"):
proxy_models[model_key] = model_state proxy_models[model_key] = model_state
# Find a concrete model for the proxy. # Find a concrete model for the proxy.
concrete_models_mapping[ concrete_models_mapping[model_key] = (
model_key self._find_concrete_model_from_proxy(
] = self._find_concrete_model_from_proxy( proxy_models,
proxy_models, model_state,
model_state, )
) )
else: else:
concrete_models_mapping[model_key] = model_key concrete_models_mapping[model_key] = model_key

View File

@ -1,6 +1,7 @@
""" """
Classes to represent the definitions of aggregate functions. Classes to represent the definitions of aggregate functions.
""" """
from django.core.exceptions import FieldError, FullResultSet from django.core.exceptions import FieldError, FullResultSet
from django.db.models.expressions import Case, Func, Star, Value, When from django.db.models.expressions import Case, Func, Star, Value, When
from django.db.models.fields import IntegerField from django.db.models.fields import IntegerField

View File

@ -2265,9 +2265,11 @@ class Model(AltersData, metaclass=ModelBase):
opts = cls._meta opts = cls._meta
valid_fields = set( valid_fields = set(
chain.from_iterable( chain.from_iterable(
(f.name, f.attname) (
if not (f.auto_created and not f.concrete) (f.name, f.attname)
else (f.field.related_query_name(),) if not (f.auto_created and not f.concrete)
else (f.field.related_query_name(),)
)
for f in chain(opts.fields, opts.related_objects) for f in chain(opts.fields, opts.related_objects)
) )
) )

View File

@ -1,6 +1,7 @@
""" """
Constants used across the ORM in general. Constants used across the ORM in general.
""" """
from enum import Enum from enum import Enum
# Separator used to split filter strings apart. # Separator used to split filter strings apart.

View File

@ -204,9 +204,11 @@ class BaseExpression:
def _parse_expressions(self, *expressions): def _parse_expressions(self, *expressions):
return [ return [
arg (
if hasattr(arg, "resolve_expression") arg
else (F(arg) if isinstance(arg, str) else Value(arg)) if hasattr(arg, "resolve_expression")
else (F(arg) if isinstance(arg, str) else Value(arg))
)
for arg in expressions for arg in expressions
] ]
@ -285,9 +287,11 @@ class BaseExpression:
c.is_summary = summarize c.is_summary = summarize
c.set_source_expressions( c.set_source_expressions(
[ [
expr.resolve_expression(query, allow_joins, reuse, summarize) (
if expr expr.resolve_expression(query, allow_joins, reuse, summarize)
else None if expr
else None
)
for expr in c.get_source_expressions() for expr in c.get_source_expressions()
] ]
) )
@ -366,22 +370,16 @@ class BaseExpression:
field = self.output_field field = self.output_field
internal_type = field.get_internal_type() internal_type = field.get_internal_type()
if internal_type == "FloatField": if internal_type == "FloatField":
return ( return lambda value, expression, connection: (
lambda value, expression, connection: None None if value is None else float(value)
if value is None
else float(value)
) )
elif internal_type.endswith("IntegerField"): elif internal_type.endswith("IntegerField"):
return ( return lambda value, expression, connection: (
lambda value, expression, connection: None None if value is None else int(value)
if value is None
else int(value)
) )
elif internal_type == "DecimalField": elif internal_type == "DecimalField":
return ( return lambda value, expression, connection: (
lambda value, expression, connection: None None if value is None else Decimal(value)
if value is None
else Decimal(value)
) )
return self._convert_value_noop return self._convert_value_noop
@ -432,9 +430,11 @@ class BaseExpression:
clone = self.copy() clone = self.copy()
clone.set_source_expressions( clone.set_source_expressions(
[ [
F(f"{prefix}{expr.name}") (
if isinstance(expr, F) F(f"{prefix}{expr.name}")
else expr.prefix_references(prefix) if isinstance(expr, F)
else expr.prefix_references(prefix)
)
for expr in self.get_source_expressions() for expr in self.get_source_expressions()
] ]
) )

View File

@ -62,6 +62,7 @@ and two directions (forward and reverse) for a total of six combinations.
If you're looking for ``ForwardManyToManyDescriptor`` or If you're looking for ``ForwardManyToManyDescriptor`` or
``ReverseManyToManyDescriptor``, use ``ManyToManyDescriptor`` instead. ``ReverseManyToManyDescriptor``, use ``ManyToManyDescriptor`` instead.
""" """
import warnings import warnings
from asgiref.sync import sync_to_async from asgiref.sync import sync_to_async

View File

@ -8,6 +8,7 @@ in the ``remote_field`` attribute of the field.
They also act as reverse fields for the purposes of the Meta API because They also act as reverse fields for the purposes of the Meta API because
they're the closest concept currently available. they're the closest concept currently available.
""" """
import warnings import warnings
from django.core import exceptions from django.core import exceptions

View File

@ -1,4 +1,5 @@
"""Database functions that do comparisons or type conversions.""" """Database functions that do comparisons or type conversions."""
from django.db import NotSupportedError from django.db import NotSupportedError
from django.db.models.expressions import Func, Value from django.db.models.expressions import Func, Value
from django.db.models.fields import TextField from django.db.models.fields import TextField

View File

@ -318,9 +318,11 @@ class TruncBase(TimezoneMixin, Transform):
"Cannot truncate DateField '%s' to %s." "Cannot truncate DateField '%s' to %s."
% ( % (
field.name, field.name,
output_field.__class__.__name__ (
if has_explicit_output_field output_field.__class__.__name__
else "DateTimeField", if has_explicit_output_field
else "DateTimeField"
),
) )
) )
elif isinstance(field, TimeField) and ( elif isinstance(field, TimeField) and (
@ -331,9 +333,11 @@ class TruncBase(TimezoneMixin, Transform):
"Cannot truncate TimeField '%s' to %s." "Cannot truncate TimeField '%s' to %s."
% ( % (
field.name, field.name,
output_field.__class__.__name__ (
if has_explicit_output_field output_field.__class__.__name__
else "DateTimeField", if has_explicit_output_field
else "DateTimeField"
),
) )
) )
return copy return copy

View File

@ -47,9 +47,11 @@ class ATan2(NumericOutputFieldMixin, Func):
clone = self.copy() clone = self.copy()
clone.set_source_expressions( clone.set_source_expressions(
[ [
Cast(expression, FloatField()) (
if isinstance(expression.output_field, IntegerField) Cast(expression, FloatField())
else expression if isinstance(expression.output_field, IntegerField)
else expression
)
for expression in self.get_source_expressions()[::-1] for expression in self.get_source_expressions()[::-1]
] ]
) )

View File

@ -14,9 +14,11 @@ class FixDecimalInputMixin:
clone = self.copy() clone = self.copy()
clone.set_source_expressions( clone.set_source_expressions(
[ [
Cast(expression, output_field) (
if isinstance(expression.output_field, FloatField) Cast(expression, output_field)
else expression if isinstance(expression.output_field, FloatField)
else expression
)
for expression in self.get_source_expressions() for expression in self.get_source_expressions()
] ]
) )

View File

@ -89,9 +89,11 @@ class ConcatPair(Func):
c = self.copy() c = self.copy()
c.set_source_expressions( c.set_source_expressions(
[ [
expression (
if isinstance(expression.output_field, (CharField, TextField)) expression
else Cast(expression, TextField()) if isinstance(expression.output_field, (CharField, TextField))
else Cast(expression, TextField())
)
for expression in c.get_source_expressions() for expression in c.get_source_expressions()
] ]
) )

View File

@ -196,9 +196,11 @@ class Index:
"" if not self.fields else " fields=%s" % repr(self.fields), "" if not self.fields else " fields=%s" % repr(self.fields),
"" if not self.expressions else " expressions=%s" % repr(self.expressions), "" if not self.expressions else " expressions=%s" % repr(self.expressions),
"" if not self.name else " name=%s" % repr(self.name), "" if not self.name else " name=%s" % repr(self.name),
"" (
if self.db_tablespace is None ""
else " db_tablespace=%s" % repr(self.db_tablespace), if self.db_tablespace is None
else " db_tablespace=%s" % repr(self.db_tablespace)
),
"" if self.condition is None else " condition=%s" % self.condition, "" if self.condition is None else " condition=%s" % self.condition,
"" if not self.include else " include=%s" % repr(self.include), "" if not self.include else " include=%s" % repr(self.include),
"" if not self.opclasses else " opclasses=%s" % repr(self.opclasses), "" if not self.opclasses else " opclasses=%s" % repr(self.opclasses),

View File

@ -273,9 +273,11 @@ class FieldGetDbPrepValueMixin:
return ( return (
"%s", "%s",
[ [
v (
if hasattr(v, "as_sql") v
else get_db_prep_value(v, connection, prepared=True) if hasattr(v, "as_sql")
else get_db_prep_value(v, connection, prepared=True)
)
for v in value for v in value
], ],
) )

View File

@ -109,9 +109,11 @@ class ModelIterable(BaseIterable):
related_objs, related_objs,
operator.attrgetter( operator.attrgetter(
*[ *[
field.attname (
if from_field == "self" field.attname
else queryset.model._meta.get_field(from_field).attname if from_field == "self"
else queryset.model._meta.get_field(from_field).attname
)
for from_field in field.from_fields for from_field in field.from_fields
] ]
), ),
@ -1391,9 +1393,7 @@ class QuerySet(AltersData):
clone._iterable_class = ( clone._iterable_class = (
NamedValuesListIterable NamedValuesListIterable
if named if named
else FlatValuesListIterable else FlatValuesListIterable if flat else ValuesListIterable
if flat
else ValuesListIterable
) )
return clone return clone
@ -1659,9 +1659,11 @@ class QuerySet(AltersData):
if names is None: if names is None:
names = set( names = set(
chain.from_iterable( chain.from_iterable(
(field.name, field.attname) (
if hasattr(field, "attname") (field.name, field.attname)
else (field.name,) if hasattr(field, "attname")
else (field.name,)
)
for field in self.model._meta.get_fields() for field in self.model._meta.get_fields()
) )
) )

View File

@ -5,6 +5,7 @@ Factored out from django.db.models.query to avoid making the main module very
large and/or so that they can be used by other modules without getting into large and/or so that they can be used by other modules without getting into
circular import difficulties. circular import difficulties.
""" """
import functools import functools
import inspect import inspect
import logging import logging

View File

@ -1224,9 +1224,9 @@ class SQLCompiler:
"field": f, "field": f,
"reverse": False, "reverse": False,
"local_setter": f.set_cached_value, "local_setter": f.set_cached_value,
"remote_setter": f.remote_field.set_cached_value "remote_setter": (
if f.unique f.remote_field.set_cached_value if f.unique else lambda x, y: None
else lambda x, y: None, ),
"from_parent": False, "from_parent": False,
} }
related_klass_infos.append(klass_info) related_klass_infos.append(klass_info)

View File

@ -2,6 +2,7 @@
Useful auxiliary data structures for query construction. Not useful outside Useful auxiliary data structures for query construction. Not useful outside
the SQL domain. the SQL domain.
""" """
import warnings import warnings
from django.core.exceptions import FullResultSet from django.core.exceptions import FullResultSet

View File

@ -6,6 +6,7 @@ themselves do not have to (and could be backed by things other than SQL
databases). The abstraction barrier only works one way: this module has to know databases). The abstraction barrier only works one way: this module has to know
all about the internals of models in order to get the information it needs. all about the internals of models in order to get the information it needs.
""" """
import copy import copy
import difflib import difflib
import functools import functools

View File

@ -1,6 +1,7 @@
""" """
Code to manage the creation and SQL rendering of 'where' constraints. Code to manage the creation and SQL rendering of 'where' constraints.
""" """
import operator import operator
from functools import reduce from functools import reduce

View File

@ -2,6 +2,7 @@
Helper functions for creating Form classes from Django models Helper functions for creating Form classes from Django models
and database field objects. and database field objects.
""" """
from itertools import chain from itertools import chain
from django.core.exceptions import ( from django.core.exceptions import (
@ -830,9 +831,12 @@ class BaseModelFormSet(BaseFormSet, AltersData):
) )
# Reduce Model instances to their primary key values # Reduce Model instances to their primary key values
row_data = tuple( row_data = tuple(
d._get_pk_val() if hasattr(d, "_get_pk_val") (
# Prevent "unhashable type: list" errors later on. d._get_pk_val()
else tuple(d) if isinstance(d, list) else d if hasattr(d, "_get_pk_val")
# Prevent "unhashable type: list" errors later on.
else tuple(d) if isinstance(d, list) else d
)
for d in row_data for d in row_data
) )
if row_data and None not in row_data: if row_data and None not in row_data:

View File

@ -101,9 +101,11 @@ class Media:
def render_js(self): def render_js(self):
return [ return [
path.__html__() (
if hasattr(path, "__html__") path.__html__()
else format_html('<script src="{}"></script>', self.absolute_path(path)) if hasattr(path, "__html__")
else format_html('<script src="{}"></script>', self.absolute_path(path))
)
for path in self._js for path in self._js
] ]
@ -113,12 +115,14 @@ class Media:
media = sorted(self._css) media = sorted(self._css)
return chain.from_iterable( return chain.from_iterable(
[ [
path.__html__() (
if hasattr(path, "__html__") path.__html__()
else format_html( if hasattr(path, "__html__")
'<link href="{}" media="{}" rel="stylesheet">', else format_html(
self.absolute_path(path), '<link href="{}" media="{}" rel="stylesheet">',
medium, self.absolute_path(path),
medium,
)
) )
for path in self._css[medium] for path in self._css[medium]
] ]

View File

@ -4,6 +4,7 @@ Multi-part parsing for file uploads.
Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to
file upload handlers for processing. file upload handlers for processing.
""" """
import base64 import base64
import binascii import binascii
import collections import collections

View File

@ -170,9 +170,11 @@ class HttpRequest:
return "%s%s%s" % ( return "%s%s%s" % (
escape_uri_path(path), escape_uri_path(path),
"/" if force_append_slash and not path.endswith("/") else "", "/" if force_append_slash and not path.endswith("/") else "",
("?" + iri_to_uri(self.META.get("QUERY_STRING", ""))) (
if self.META.get("QUERY_STRING", "") ("?" + iri_to_uri(self.META.get("QUERY_STRING", "")))
else "", if self.META.get("QUERY_STRING", "")
else ""
),
) )
def get_signed_cookie(self, key, default=RAISE_ERROR, salt="", max_age=None): def get_signed_cookie(self, key, default=RAISE_ERROR, salt="", max_age=None):

View File

@ -4,6 +4,7 @@ Cross Site Request Forgery Middleware.
This module provides a middleware that implements protection This module provides a middleware that implements protection
against request forgeries from other sites. against request forgeries from other sites.
""" """
import logging import logging
import string import string
from collections import defaultdict from collections import defaultdict

View File

@ -3,6 +3,7 @@ This module collects helper functions and classes that "span" multiple levels
of MVC. In other words, these functions/classes introduce controlled coupling of MVC. In other words, these functions/classes introduce controlled coupling
for convenience's sake. for convenience's sake.
""" """
from django.http import ( from django.http import (
Http404, Http404,
HttpResponse, HttpResponse,

View File

@ -1,4 +1,5 @@
"""Default variable filters.""" """Default variable filters."""
import random as random_module import random as random_module
import re import re
import types import types

View File

@ -1,4 +1,5 @@
"""Default tags used by the template system, available to all templates.""" """Default tags used by the template system, available to all templates."""
import re import re
import sys import sys
import warnings import warnings

View File

@ -70,9 +70,11 @@ class Engine:
self.__class__.__qualname__, self.__class__.__qualname__,
"" if not self.dirs else " dirs=%s" % repr(self.dirs), "" if not self.dirs else " dirs=%s" % repr(self.dirs),
self.app_dirs, self.app_dirs,
"" (
if not self.context_processors ""
else " context_processors=%s" % repr(self.context_processors), if not self.context_processors
else " context_processors=%s" % repr(self.context_processors)
),
self.debug, self.debug,
repr(self.loaders), repr(self.loaders),
repr(self.string_if_invalid), repr(self.string_if_invalid),

View File

@ -1,6 +1,7 @@
""" """
Parser and utilities for the smart 'if' tag Parser and utilities for the smart 'if' tag
""" """
# Using a simple top down parser, as described here: # Using a simple top down parser, as described here:
# http://effbot.org/zone/simple-top-down-parsing.htm. # http://effbot.org/zone/simple-top-down-parsing.htm.
# 'led' = left denotation # 'led' = left denotation

View File

@ -1,4 +1,5 @@
"""Compare two HTML documents.""" """Compare two HTML documents."""
import html import html
from html.parser import HTMLParser from html.parser import HTMLParser

View File

@ -1,4 +1,5 @@
"""Functions for use in URLsconfs.""" """Functions for use in URLsconfs."""
from functools import partial from functools import partial
from importlib import import_module from importlib import import_module

Some files were not shown because too many files have changed in this diff Show More