Skip to content

Commit

Permalink
Applied Black's 2024 stable style.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixxm authored Jan 26, 2024
1 parent 3f6d939 commit 305757a
Show file tree
Hide file tree
Showing 235 changed files with 809 additions and 602 deletions.
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: 23.12.1
rev: 24.1.0
hooks:
- id: black
exclude: \.py-tpl$
Expand All @@ -9,7 +9,7 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.12.1
- black==24.1.0
files: 'docs/.*\.txt$'
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
Expand Down
1 change: 1 addition & 0 deletions django/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Example: python -m django check
"""

from django.core import management

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions django/contrib/admin/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Each filter subclass knows how to display a filter for a field that passes a
certain test -- e.g. being a DateField or ForeignKey.
"""

import datetime

from django.contrib.admin.exceptions import NotRegistered
Expand Down
14 changes: 8 additions & 6 deletions django/contrib/admin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,9 +1759,9 @@ def get_inline_formsets(self, request, formsets, inline_instances, obj=None):
has_delete_permission = inline.has_delete_permission(request, obj)
else:
# Disable all edit-permissions, and override formset settings.
has_add_permission = (
has_change_permission
) = has_delete_permission = False
has_add_permission = has_change_permission = has_delete_permission = (
False
)
formset.extra = formset.max_num = 0
has_view_permission = inline.has_view_permission(request, obj)
prepopulated = dict(inline.get_prepopulated_fields(request, obj))
Expand Down Expand Up @@ -1896,9 +1896,11 @@ def _changeform_view(self, request, object_id, form_url, extra_context):
form,
list(fieldsets),
# 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)
else {},
(
self.get_prepopulated_fields(request, obj)
if add or self.has_change_permission(request, obj)
else {}
),
readonly_fields,
model_admin=self,
)
Expand Down
14 changes: 8 additions & 6 deletions django/contrib/admin/templatetags/admin_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def make_qs_param(t, n):
"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_toggle": cl.get_query_string({ORDER_VAR: ".".join(o_list_toggle)}),
"class_attrib": format_html(' class="{}"', " ".join(th_classes))
if th_classes
else "",
"class_attrib": (
format_html(' class="{}"', " ".join(th_classes)) if th_classes else ""
),
}


Expand Down Expand Up @@ -270,9 +270,11 @@ def link_in_col(is_first, field_name, cl):
link_or_text = format_html(
'<a href="{}"{}>{}</a>',
url,
format_html(' data-popup-opener="{}"', value)
if cl.is_popup
else "",
(
format_html(' data-popup-opener="{}"', value)
if cl.is_popup
else ""
),
result_repr,
)

Expand Down
1 change: 1 addition & 0 deletions django/contrib/admin/widgets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Form Widget classes specific to the Django admin site.
"""

import copy
import json

Expand Down
1 change: 1 addition & 0 deletions django/contrib/auth/base_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module allows importing AbstractBaseUser even when django.contrib.auth is
not in INSTALLED_APPS.
"""

import unicodedata

from django.conf import settings
Expand Down
1 change: 1 addition & 0 deletions django/contrib/auth/management/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Creates permissions for all installed apps that need permissions.
"""

import getpass
import unicodedata

Expand Down
23 changes: 14 additions & 9 deletions django/contrib/auth/management/commands/createsuperuser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Management utility to create superusers.
"""

import getpass
import os
import sys
Expand Down Expand Up @@ -271,15 +272,19 @@ def _get_input_message(self, field, default=None):
return "%s%s%s: " % (
capfirst(field.verbose_name),
" (leave blank to use '%s')" % default if default else "",
" (%s.%s)"
% (
field.remote_field.model._meta.object_name,
field.m2m_target_field_name()
if field.many_to_many
else field.remote_field.field_name,
)
if field.remote_field
else "",
(
" (%s.%s)"
% (
field.remote_field.model._meta.object_name,
(
field.m2m_target_field_name()
if field.many_to_many
else field.remote_field.field_name
),
)
if field.remote_field
else ""
),
)

@cached_property
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/oracle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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.
"""

from django.contrib.gis.db import models
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/oracle/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
support for an internal JVM, and Java libraries are required to use
the WKT constructors.
"""

import re

from django.contrib.gis.db import models
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/postgis/adapter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
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.geos import GEOSGeometry
from django.db.backends.postgresql.psycopg_any import sql
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/postgis/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
PostGIS to GDAL conversion constant definitions
"""

# 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]

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/postgis/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The GeometryColumns and SpatialRefSys models for the PostGIS backend.
"""

from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
from django.db import models

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/spatialite/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The GeometryColumns and SpatialRefSys models for the SpatiaLite backend.
"""

from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
from django.db import models

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/spatialite/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SQL functions reference lists:
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.backends.base.operations import BaseSpatialOperations
from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter
Expand Down
14 changes: 8 additions & 6 deletions django/contrib/gis/db/models/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ def as_sqlite(self, compiler, connection, **extra_context):
copy = self.copy()
copy.set_source_expressions(
[
Value(float(expr.value))
if hasattr(expr, "value") and isinstance(expr.value, Decimal)
else expr
(
Value(float(expr.value))
if hasattr(expr, "value") and isinstance(expr.value, Decimal)
else expr
)
for expr in copy.get_source_expressions()
]
)
Expand Down Expand Up @@ -349,9 +351,9 @@ def as_postgresql(self, compiler, connection, **extra_context):
def as_sqlite(self, compiler, connection, **extra_context):
if self.geo_field.geodetic(connection):
# SpatiaLite returns NULL instead of zero on geodetic coordinates
extra_context[
"template"
] = "COALESCE(%(function)s(%(expressions)s, %(spheroid)s), 0)"
extra_context["template"] = (
"COALESCE(%(function)s(%(expressions)s, %(spheroid)s), 0)"
)
extra_context["spheroid"] = int(bool(self.spheroid))
return super().as_sql(compiler, connection, **extra_context)

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/models/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Thanks to Robert Coup for providing this functionality (see #4322).
"""

from django.db.models.query_utils import DeferredAttribute


Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/models/sql/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module holds simple classes to convert geospatial values from the
database.
"""

from decimal import Decimal

from django.contrib.gis.measure import Area, Distance
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
library on your system.
"""

from django.contrib.gis.gdal.datasource import DataSource
from django.contrib.gis.gdal.driver import Driver
from django.contrib.gis.gdal.envelope import Envelope
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# OFTReal returns floats, all else returns string.
val = field.value
"""

from pathlib import Path

from django.contrib.gis.gdal.base import GDALBase
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| |
Lower left (min_x, min_y) o----------+
"""

from ctypes import Structure, c_double

from django.contrib.gis.gdal.error import GDALException
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
>>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
True True
"""

import sys
import warnings
from binascii import b2a_hex
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/prototypes/ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*,
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 django.contrib.gis.gdal.envelope import OGREnvelope
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/prototypes/errcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module houses the error-checking routines used by the GDAL
ctypes prototypes.
"""

from ctypes import c_void_p, string_at

from django.contrib.gis.gdal.error import GDALException, SRSException, check_err
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/prototypes/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains functions that generate ctypes prototypes for the
GDAL routines.
"""

from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_int64, c_void_p
from functools import partial

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/prototypes/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module houses the ctypes function prototypes for GDAL DataSource (raster)
related data structures.
"""

from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_void_p
from functools import partial

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/raster/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
GDAL - Constant definitions
"""

from ctypes import (
c_double,
c_float,
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/gdal/srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
>>> print(srs.name)
NAD83 / Texas South Central
"""

from ctypes import byref, c_char_p, c_int
from enum import IntEnum
from types import NoneType
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
The GeoDjango GEOS module. Please consult the GeoDjango documentation
for more details: https://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
"""

from .collections import ( # NOQA
GeometryCollection,
MultiLineString,
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module houses the Geometry Collection objects:
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
"""

from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin
from django.contrib.gis.geos.libgeos import GEOM_PTR
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/coordseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
by GEOSGeometry to house the actual coordinates of the Point,
LineString, and LinearRing geometries.
"""

from ctypes import byref, c_byte, c_double, c_uint

from django.contrib.gis.geos import prototypes as capi
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
inherit from this object.
"""

import re
from ctypes import addressof, byref, c_double

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
objects. Specifically, this has Python implementations of WKB/WKT
reader and writer classes.
"""

from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.prototypes.io import (
WKBWriter,
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/libgeos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
This module also houses GEOS Pointer utilities, including
get_pointer_arr(), and GEOM_PTR.
"""

import logging
import os
from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_char_p
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/prototypes/errcheck.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Error checking functions for GEOS ctypes prototype functions.
"""

from ctypes import c_void_p, string_at

from django.contrib.gis.geos.error import GEOSException
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/geos/prototypes/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module is for the miscellaneous GEOS routines, particularly the
ones that return the area, distance, and length.
"""

from ctypes import POINTER, c_double, c_int

from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory
Expand Down
Loading

0 comments on commit 305757a

Please sign in to comment.