summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2025-03-01 19:41:37 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2025-03-01 19:47:17 +0100
commit53bb1d5a240a39d35abc11c6477ac5465c5fac2c (patch)
treeca10c5869c7bcbcb219eadb0c93ba297d9bbd4b4
parentb8ceda4a518de960c2cf2b4b1ff70cbd10c0ecda (diff)
[5.2.x] Applied Black's 2025 stable style.
https://github.com/psf/black/releases/tag/25.1.0 Backport of ff3aaf036f0cb66cd8f404cd51c603e68aaa7676 from main
-rw-r--r--.pre-commit-config.yaml6
-rw-r--r--django/contrib/gis/db/backends/oracle/models.py14
-rw-r--r--django/contrib/gis/db/backends/oracle/operations.py12
-rw-r--r--django/contrib/gis/db/backends/postgis/adapter.py2
-rw-r--r--django/contrib/gis/db/backends/postgis/models.py2
-rw-r--r--django/contrib/gis/db/backends/spatialite/models.py2
-rw-r--r--django/contrib/gis/gdal/__init__.py34
-rw-r--r--django/contrib/gis/gdal/datasource.py53
-rw-r--r--django/contrib/gis/gdal/envelope.py19
-rw-r--r--django/contrib/gis/gdal/error.py6
-rw-r--r--django/contrib/gis/gdal/geometries.py70
-rw-r--r--django/contrib/gis/gdal/prototypes/ds.py6
-rw-r--r--django/contrib/gis/gdal/prototypes/errcheck.py4
-rw-r--r--django/contrib/gis/gdal/prototypes/generation.py4
-rw-r--r--django/contrib/gis/gdal/srs.py51
-rw-r--r--django/contrib/gis/geos/collections.py4
-rw-r--r--django/contrib/gis/geos/coordseq.py6
-rw-r--r--django/contrib/gis/geos/error.py1
-rw-r--r--django/contrib/gis/geos/geometry.py4
-rw-r--r--django/contrib/gis/geos/libgeos.py10
-rw-r--r--django/contrib/gis/geos/prototypes/__init__.py6
-rw-r--r--django/contrib/gis/geos/prototypes/coordseq.py2
-rw-r--r--django/contrib/gis/geos/prototypes/errcheck.py2
-rw-r--r--django/contrib/gis/geos/prototypes/geom.py3
-rw-r--r--django/contrib/gis/geos/prototypes/misc.py4
-rw-r--r--django/contrib/gis/geos/prototypes/predicates.py6
-rw-r--r--django/contrib/gis/geos/prototypes/topology.py5
-rw-r--r--django/contrib/gis/utils/__init__.py2
-rw-r--r--django/contrib/gis/utils/layermapping.py8
-rw-r--r--django/core/cache/backends/base.py1
-rw-r--r--django/core/cache/backends/db.py1
-rw-r--r--django/core/cache/backends/filebased.py1
-rw-r--r--django/core/cache/backends/locmem.py1
-rw-r--r--django/forms/forms.py1
-rw-r--r--django/template/context.py1
-rw-r--r--tests/admin_views/models.py1
-rw-r--r--tests/admin_views/tests.py2
-rw-r--r--tests/auth_tests/test_validators.py6
-rw-r--r--tests/backends/tests.py2
-rw-r--r--tests/forms_tests/tests/test_utils.py4
-rw-r--r--tests/gis_tests/distapp/models.py7
-rw-r--r--tests/model_fields/test_binaryfield.py2
-rw-r--r--tests/postgres_tests/test_constraints.py2
-rw-r--r--tests/serializers/test_data.py2
-rw-r--r--tests/serializers/test_xml.py2
-rw-r--r--tests/utils_tests/test_text.py14
46 files changed, 213 insertions, 185 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 5f20568b34..0bd515f100 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,15 +1,15 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
- rev: 24.10.0
+ rev: 25.1.0
hooks:
- id: black
exclude: \.py-tpl$
- repo: https://github.com/adamchainz/blacken-docs
- rev: 1.19.0
+ rev: 1.19.1
hooks:
- id: blacken-docs
additional_dependencies:
- - black==24.10.0
+ - black==25.1.0
files: 'docs/.*\.txt$'
args: ["--rst-literal-block"]
- repo: https://github.com/PyCQA/isort
diff --git a/django/contrib/gis/db/backends/oracle/models.py b/django/contrib/gis/db/backends/oracle/models.py
index af749c3435..7a69fbc4d0 100644
--- a/django/contrib/gis/db/backends/oracle/models.py
+++ b/django/contrib/gis/db/backends/oracle/models.py
@@ -1,11 +1,11 @@
"""
- The GeometryColumns and SpatialRefSys models for the Oracle spatial
- backend.
+The GeometryColumns and SpatialRefSys models for the Oracle spatial
+backend.
- It should be noted that Oracle Spatial does not have database tables
- named according to the OGC standard, so the closest analogs are used.
- 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.
+It should be noted that Oracle Spatial does not have database tables
+named according to the OGC standard, so the closest analogs are used.
+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
@@ -14,6 +14,7 @@ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
class OracleGeometryColumns(models.Model):
"Maps to the Oracle USER_SDO_GEOM_METADATA table."
+
table_name = models.CharField(max_length=32)
column_name = models.CharField(max_length=1024)
srid = models.IntegerField(primary_key=True)
@@ -46,6 +47,7 @@ class OracleGeometryColumns(models.Model):
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
"Maps to the Oracle MDSYS.CS_SRS table."
+
cs_name = models.CharField(max_length=68)
srid = models.IntegerField(primary_key=True)
auth_srid = models.IntegerField()
diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py
index eb86dc39de..1be7668017 100644
--- a/django/contrib/gis/db/backends/oracle/operations.py
+++ b/django/contrib/gis/db/backends/oracle/operations.py
@@ -1,11 +1,11 @@
"""
- This module contains the spatial lookup types, and the `get_geo_where_clause`
- routine for Oracle Spatial.
+This module contains the spatial lookup types, and the `get_geo_where_clause`
+routine for Oracle Spatial.
- Please note that WKT support is broken on the XE version, and thus
- this backend will not work on such platforms. Specifically, XE lacks
- support for an internal JVM, and Java libraries are required to use
- the WKT constructors.
+Please note that WKT support is broken on the XE version, and thus
+this backend will not work on such platforms. Specifically, XE lacks
+support for an internal JVM, and Java libraries are required to use
+the WKT constructors.
"""
import re
diff --git a/django/contrib/gis/db/backends/postgis/adapter.py b/django/contrib/gis/db/backends/postgis/adapter.py
index c9715e1756..581fc23b0b 100644
--- a/django/contrib/gis/db/backends/postgis/adapter.py
+++ b/django/contrib/gis/db/backends/postgis/adapter.py
@@ -1,5 +1,5 @@
"""
- 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
diff --git a/django/contrib/gis/db/backends/postgis/models.py b/django/contrib/gis/db/backends/postgis/models.py
index e35ef75ce9..c3747d7353 100644
--- a/django/contrib/gis/db/backends/postgis/models.py
+++ b/django/contrib/gis/db/backends/postgis/models.py
@@ -1,5 +1,5 @@
"""
- 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
diff --git a/django/contrib/gis/db/backends/spatialite/models.py b/django/contrib/gis/db/backends/spatialite/models.py
index 0f5f7b55ef..1d564b0ac0 100644
--- a/django/contrib/gis/db/backends/spatialite/models.py
+++ b/django/contrib/gis/db/backends/spatialite/models.py
@@ -1,5 +1,5 @@
"""
- 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
diff --git a/django/contrib/gis/gdal/__init__.py b/django/contrib/gis/gdal/__init__.py
index e63808d39d..37c9273666 100644
--- a/django/contrib/gis/gdal/__init__.py
+++ b/django/contrib/gis/gdal/__init__.py
@@ -1,29 +1,29 @@
"""
- This module houses ctypes interfaces for GDAL objects. The following GDAL
- objects are supported:
+This module houses ctypes interfaces for GDAL objects. The following GDAL
+objects are supported:
- CoordTransform: Used for coordinate transformations from one spatial
- reference system to another.
+CoordTransform: Used for coordinate transformations from one spatial
+ reference system to another.
- Driver: Wraps an OGR data source driver.
+Driver: Wraps an OGR data source driver.
- DataSource: Wrapper for the OGR data source object, supports
- OGR-supported data sources.
+DataSource: Wrapper for the OGR data source object, supports
+ OGR-supported data sources.
- Envelope: A ctypes structure for bounding boxes (GDAL library
- not required).
+Envelope: A ctypes structure for bounding boxes (GDAL library
+ not required).
- OGRGeometry: Object for accessing OGR Geometry functionality.
+OGRGeometry: Object for accessing OGR Geometry functionality.
- OGRGeomType: A class for representing the different OGR Geometry
- types (GDAL library not required).
+OGRGeomType: A class for representing the different OGR Geometry
+ types (GDAL library not required).
- SpatialReference: Represents OSR Spatial Reference objects.
+SpatialReference: Represents OSR Spatial Reference objects.
- The GDAL library will be imported from the system path using the default
- library name for the current OS. The default library path may be overridden
- by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
- library on your system.
+The GDAL library will be imported from the system path using the default
+library name for the current OS. The default library path may be overridden
+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
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index 2ce859ad13..2c9d47918f 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -1,37 +1,37 @@
"""
- DataSource is a wrapper for the OGR Data Source object, which provides
- an interface for reading vector geometry data from many different file
- formats (including ESRI shapefiles).
+DataSource is a wrapper for the OGR Data Source object, which provides
+an interface for reading vector geometry data from many different file
+formats (including ESRI shapefiles).
- When instantiating a DataSource object, use the filename of a
- GDAL-supported data source. For example, a SHP file or a
- TIGER/Line file from the government.
+When instantiating a DataSource object, use the filename of a
+GDAL-supported data source. For example, a SHP file or a
+TIGER/Line file from the government.
- The ds_driver keyword is used internally when a ctypes pointer
- is passed in directly.
+The ds_driver keyword is used internally when a ctypes pointer
+is passed in directly.
- Example:
- ds = DataSource('/home/foo/bar.shp')
- for layer in ds:
- for feature in layer:
- # Getting the geometry for the feature.
- g = feature.geom
+Example:
+ ds = DataSource('/home/foo/bar.shp')
+ for layer in ds:
+ for feature in layer:
+ # Getting the geometry for the feature.
+ g = feature.geom
- # Getting the 'description' field for the feature.
- desc = feature['description']
+ # Getting the 'description' field for the feature.
+ desc = feature['description']
- # We can also increment through all of the fields
- # attached to this feature.
- for field in feature:
- # Get the name of the field (e.g. 'description')
- nm = field.name
+ # We can also increment through all of the fields
+ # attached to this feature.
+ for field in feature:
+ # Get the name of the field (e.g. 'description')
+ nm = field.name
- # Get the type (integer) of the field, e.g. 0 => OFTInteger
- t = field.type
+ # Get the type (integer) of the field, e.g. 0 => OFTInteger
+ t = field.type
- # Returns the value the field; OFTIntegers return ints,
- # OFTReal returns floats, all else returns string.
- val = field.value
+ # Returns the value the field; OFTIntegers return ints,
+ # OFTReal returns floats, all else returns string.
+ val = field.value
"""
from pathlib import Path
@@ -50,6 +50,7 @@ from django.utils.encoding import force_bytes, force_str
# The OGR_DS_* routines are relevant here.
class DataSource(GDALBase):
"Wraps an OGR Data Source object."
+
destructor = capi.destroy_ds
def __init__(self, ds_input, ds_driver=False, write=False, encoding="utf-8"):
diff --git a/django/contrib/gis/gdal/envelope.py b/django/contrib/gis/gdal/envelope.py
index 05832bd7cc..24383de196 100644
--- a/django/contrib/gis/gdal/envelope.py
+++ b/django/contrib/gis/gdal/envelope.py
@@ -1,14 +1,14 @@
"""
- The GDAL/OGR library uses an Envelope structure to hold the bounding
- box information for a geometry. The envelope (bounding box) contains
- two pairs of coordinates, one for the lower left coordinate and one
- for the upper right coordinate:
+The GDAL/OGR library uses an Envelope structure to hold the bounding
+box information for a geometry. The envelope (bounding box) contains
+two pairs of coordinates, one for the lower left coordinate and one
+for the upper right coordinate:
- +----------o Upper right; (max_x, max_y)
- | |
- | |
- | |
- Lower left (min_x, min_y) o----------+
+ +----------o Upper right; (max_x, max_y)
+ | |
+ | |
+ | |
+Lower left (min_x, min_y) o----------+
"""
from ctypes import Structure, c_double
@@ -21,6 +21,7 @@ from django.contrib.gis.gdal.error import GDALException
# https://gdal.org/doxygen/ogr__core_8h_source.html
class OGREnvelope(Structure):
"Represent the OGREnvelope C Structure."
+
_fields_ = [
("MinX", c_double),
("MaxX", c_double),
diff --git a/django/contrib/gis/gdal/error.py b/django/contrib/gis/gdal/error.py
index df19c2e4a7..08ad5c36b7 100644
--- a/django/contrib/gis/gdal/error.py
+++ b/django/contrib/gis/gdal/error.py
@@ -1,7 +1,7 @@
"""
- This module houses the GDAL & SRS Exception objects, and the
- check_err() routine which checks the status code returned by
- GDAL/OGR methods.
+This module houses the GDAL & SRS Exception objects, and the
+check_err() routine which checks the status code returned by
+GDAL/OGR methods.
"""
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index 9e712037c0..33e7de0a96 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -1,42 +1,42 @@
"""
- The OGRGeometry is a wrapper for using the OGR Geometry class
- (see https://gdal.org/api/ogrgeometry_cpp.html#_CPPv411OGRGeometry).
- OGRGeometry may be instantiated when reading geometries from OGR Data Sources
- (e.g. SHP files), or when given OGC WKT (a string).
+The OGRGeometry is a wrapper for using the OGR Geometry class
+(see https://gdal.org/api/ogrgeometry_cpp.html#_CPPv411OGRGeometry).
+OGRGeometry may be instantiated when reading geometries from OGR Data Sources
+(e.g. SHP files), or when given OGC WKT (a string).
- While the 'full' API is not present yet, the API is "pythonic" unlike
- the traditional and "next-generation" OGR Python bindings. One major
- advantage OGR Geometries have over their GEOS counterparts is support
- for spatial reference systems and their transformation.
+While the 'full' API is not present yet, the API is "pythonic" unlike
+the traditional and "next-generation" OGR Python bindings. One major
+advantage OGR Geometries have over their GEOS counterparts is support
+for spatial reference systems and their transformation.
- Example:
- >>> from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, SpatialReference
- >>> wkt1, wkt2 = 'POINT(-90 30)', 'POLYGON((0 0, 5 0, 5 5, 0 5)'
- >>> pnt = OGRGeometry(wkt1)
- >>> print(pnt)
- POINT (-90 30)
- >>> mpnt = OGRGeometry(OGRGeomType('MultiPoint'), SpatialReference('WGS84'))
- >>> mpnt.add(wkt1)
- >>> mpnt.add(wkt1)
- >>> print(mpnt)
- MULTIPOINT (-90 30,-90 30)
- >>> print(mpnt.srs.name)
- WGS 84
- >>> print(mpnt.srs.proj)
- +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
- >>> mpnt.transform(SpatialReference('NAD27'))
- >>> print(mpnt.proj)
- +proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
- >>> print(mpnt)
- MULTIPOINT (-89.99993037860248 29.99979788655764,-89.99993037860248 29.99979788655764)
+Example:
+ >>> from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, SpatialReference
+ >>> wkt1, wkt2 = 'POINT(-90 30)', 'POLYGON((0 0, 5 0, 5 5, 0 5)'
+ >>> pnt = OGRGeometry(wkt1)
+ >>> print(pnt)
+ POINT (-90 30)
+ >>> mpnt = OGRGeometry(OGRGeomType('MultiPoint'), SpatialReference('WGS84'))
+ >>> mpnt.add(wkt1)
+ >>> mpnt.add(wkt1)
+ >>> print(mpnt)
+ MULTIPOINT (-90 30,-90 30)
+ >>> print(mpnt.srs.name)
+ WGS 84
+ >>> print(mpnt.srs.proj)
+ +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
+ >>> mpnt.transform(SpatialReference('NAD27'))
+ >>> print(mpnt.proj)
+ +proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
+ >>> print(mpnt)
+ MULTIPOINT (-89.99993037860248 29.99979788655764,-89.99993037860248 29.99979788655764)
- The OGRGeomType class is to make it easy to specify an OGR geometry type:
- >>> from django.contrib.gis.gdal import OGRGeomType
- >>> gt1 = OGRGeomType(3) # Using an integer for the type
- >>> gt2 = OGRGeomType('Polygon') # Using a string
- >>> gt3 = OGRGeomType('POLYGON') # It's case-insensitive
- >>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
- True True
+ The OGRGeomType class is to make it easy to specify an OGR geometry type:
+ >>> from django.contrib.gis.gdal import OGRGeomType
+ >>> gt1 = OGRGeomType(3) # Using an integer for the type
+ >>> gt2 = OGRGeomType('Polygon') # Using a string
+ >>> gt3 = OGRGeomType('POLYGON') # It's case-insensitive
+ >>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
+ True True
"""
import sys
diff --git a/django/contrib/gis/gdal/prototypes/ds.py b/django/contrib/gis/gdal/prototypes/ds.py
index 71148f1b55..0434bc5125 100644
--- a/django/contrib/gis/gdal/prototypes/ds.py
+++ b/django/contrib/gis/gdal/prototypes/ds.py
@@ -1,7 +1,7 @@
"""
- This module houses the ctypes function prototypes for OGR DataSource
- related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*,
- OGR_Fld_* routines are relevant here.
+This module houses the ctypes function prototypes for OGR DataSource
+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
diff --git a/django/contrib/gis/gdal/prototypes/errcheck.py b/django/contrib/gis/gdal/prototypes/errcheck.py
index d37e81cdf6..d970b2e4d2 100644
--- a/django/contrib/gis/gdal/prototypes/errcheck.py
+++ b/django/contrib/gis/gdal/prototypes/errcheck.py
@@ -1,6 +1,6 @@
"""
- This module houses the error-checking routines used by the GDAL
- ctypes prototypes.
+This module houses the error-checking routines used by the GDAL
+ctypes prototypes.
"""
from ctypes import c_void_p, string_at
diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py
index 4d34a96e70..42665a2661 100644
--- a/django/contrib/gis/gdal/prototypes/generation.py
+++ b/django/contrib/gis/gdal/prototypes/generation.py
@@ -1,6 +1,6 @@
"""
- This module contains functions that generate ctypes prototypes for the
- GDAL routines.
+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
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 0a8d95c1fc..8bf72ab63d 100644
--- a/django/contrib/gis/gdal/srs.py
+++ b/django/contrib/gis/gdal/srs.py
@@ -1,30 +1,30 @@
"""
- The Spatial Reference class, represents OGR Spatial Reference objects.
+The Spatial Reference class, represents OGR Spatial Reference objects.
- Example:
- >>> from django.contrib.gis.gdal import SpatialReference
- >>> srs = SpatialReference('WGS84')
- >>> print(srs)
- GEOGCS["WGS 84",
- DATUM["WGS_1984",
- SPHEROID["WGS 84",6378137,298.257223563,
- AUTHORITY["EPSG","7030"]],
- TOWGS84[0,0,0,0,0,0,0],
- AUTHORITY["EPSG","6326"]],
- PRIMEM["Greenwich",0,
- AUTHORITY["EPSG","8901"]],
- UNIT["degree",0.01745329251994328,
- AUTHORITY["EPSG","9122"]],
- AUTHORITY["EPSG","4326"]]
- >>> print(srs.proj)
- +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
- >>> print(srs.ellipsoid)
- (6378137.0, 6356752.3142451793, 298.25722356300003)
- >>> print(srs.projected, srs.geographic)
- False True
- >>> srs.import_epsg(32140)
- >>> print(srs.name)
- NAD83 / Texas South Central
+Example:
+>>> from django.contrib.gis.gdal import SpatialReference
+>>> srs = SpatialReference('WGS84')
+>>> print(srs)
+GEOGCS["WGS 84",
+ DATUM["WGS_1984",
+ SPHEROID["WGS 84",6378137,298.257223563,
+ AUTHORITY["EPSG","7030"]],
+ TOWGS84[0,0,0,0,0,0,0],
+ AUTHORITY["EPSG","6326"]],
+ PRIMEM["Greenwich",0,
+ AUTHORITY["EPSG","8901"]],
+ UNIT["degree",0.01745329251994328,
+ AUTHORITY["EPSG","9122"]],
+ AUTHORITY["EPSG","4326"]]
+>>> print(srs.proj)
++proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
+>>> print(srs.ellipsoid)
+(6378137.0, 6356752.3142451793, 298.25722356300003)
+>>> print(srs.projected, srs.geographic)
+False True
+>>> srs.import_epsg(32140)
+>>> print(srs.name)
+NAD83 / Texas South Central
"""
from ctypes import byref, c_char_p, c_int
@@ -345,6 +345,7 @@ class SpatialReference(GDALBase):
class CoordTransform(GDALBase):
"The coordinate system transformation object."
+
destructor = capi.destroy_ct
def __init__(self, source, target):
diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py
index 35262a5622..41a647f234 100644
--- a/django/contrib/gis/geos/collections.py
+++ b/django/contrib/gis/geos/collections.py
@@ -1,6 +1,6 @@
"""
- This module houses the Geometry Collection objects:
- GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
+This module houses the Geometry Collection objects:
+GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
"""
from django.contrib.gis.geos import prototypes as capi
diff --git a/django/contrib/gis/geos/coordseq.py b/django/contrib/gis/geos/coordseq.py
index 15400e08fe..484b53ab5f 100644
--- a/django/contrib/gis/geos/coordseq.py
+++ b/django/contrib/gis/geos/coordseq.py
@@ -1,7 +1,7 @@
"""
- This module houses the GEOSCoordSeq object, which is used internally
- by GEOSGeometry to house the actual coordinates of the Point,
- LineString, and LinearRing geometries.
+This module houses the GEOSCoordSeq object, which is used internally
+by GEOSGeometry to house the actual coordinates of the Point,
+LineString, and LinearRing geometries.
"""
from ctypes import byref, c_byte, c_double, c_uint
diff --git a/django/contrib/gis/geos/error.py b/django/contrib/gis/geos/error.py
index af2ac2fd42..970f42effb 100644
--- a/django/contrib/gis/geos/error.py
+++ b/django/contrib/gis/geos/error.py
@@ -1,3 +1,4 @@
class GEOSException(Exception):
"The base GEOS exception, indicates a GEOS-related error."
+
pass
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index 8bbe2c264a..42aee77f24 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -1,6 +1,6 @@
"""
- This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
- inherit from this object.
+This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
+inherit from this object.
"""
import re
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index b883c6c090..2707fef283 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -1,10 +1,10 @@
"""
- This module houses the ctypes initialization procedures, as well
- as the notice and error handler function callbacks (get called
- when an error occurs in GEOS).
+This module houses the ctypes initialization procedures, as well
+as the notice and error handler function callbacks (get called
+when an error occurs in GEOS).
- This module also houses GEOS Pointer utilities, including
- get_pointer_arr(), and GEOM_PTR.
+This module also houses GEOS Pointer utilities, including
+get_pointer_arr(), and GEOM_PTR.
"""
import logging
diff --git a/django/contrib/gis/geos/prototypes/__init__.py b/django/contrib/gis/geos/prototypes/__init__.py
index 3e980b9b89..d7132284b9 100644
--- a/django/contrib/gis/geos/prototypes/__init__.py
+++ b/django/contrib/gis/geos/prototypes/__init__.py
@@ -1,7 +1,7 @@
"""
- This module contains all of the GEOS ctypes function prototypes. Each
- prototype handles the interaction between the GEOS library and Python
- via ctypes.
+This module contains all of the GEOS ctypes function prototypes. Each
+prototype handles the interaction between the GEOS library and Python
+via ctypes.
"""
from django.contrib.gis.geos.prototypes.coordseq import ( # NOQA
diff --git a/django/contrib/gis/geos/prototypes/coordseq.py b/django/contrib/gis/geos/prototypes/coordseq.py
index ed05de99f4..cfc242c00d 100644
--- a/django/contrib/gis/geos/prototypes/coordseq.py
+++ b/django/contrib/gis/geos/prototypes/coordseq.py
@@ -23,6 +23,7 @@ def check_cs_get(result, func, cargs):
# ## Coordinate sequence prototype factory classes. ##
class CsInt(GEOSFuncFactory):
"For coordinate sequence routines that return an integer."
+
argtypes = [CS_PTR, POINTER(c_uint)]
restype = c_int
errcheck = staticmethod(check_cs_get)
@@ -30,6 +31,7 @@ class CsInt(GEOSFuncFactory):
class CsOperation(GEOSFuncFactory):
"For coordinate sequence operations."
+
restype = c_int
def __init__(self, *args, ordinate=False, get=False, **kwargs):
diff --git a/django/contrib/gis/geos/prototypes/errcheck.py b/django/contrib/gis/geos/prototypes/errcheck.py
index 42b24c2891..5ee43999fa 100644
--- a/django/contrib/gis/geos/prototypes/errcheck.py
+++ b/django/contrib/gis/geos/prototypes/errcheck.py
@@ -1,5 +1,5 @@
"""
- Error checking functions for GEOS ctypes prototype functions.
+Error checking functions for GEOS ctypes prototype functions.
"""
from ctypes import c_void_p, string_at
diff --git a/django/contrib/gis/geos/prototypes/geom.py b/django/contrib/gis/geos/prototypes/geom.py
index a456acd0c1..3996544033 100644
--- a/django/contrib/gis/geos/prototypes/geom.py
+++ b/django/contrib/gis/geos/prototypes/geom.py
@@ -25,12 +25,14 @@ class geos_char_p(c_char_p):
# ### ctypes factory classes ###
class GeomOutput(GEOSFuncFactory):
"For GEOS routines that return a geometry."
+
restype = GEOM_PTR
errcheck = staticmethod(check_geom)
class IntFromGeom(GEOSFuncFactory):
"Argument is a geometry, return type is an integer."
+
argtypes = [GEOM_PTR]
restype = c_int
errcheck = staticmethod(check_minus_one)
@@ -38,6 +40,7 @@ class IntFromGeom(GEOSFuncFactory):
class StringFromGeom(GEOSFuncFactory):
"Argument is a Geometry, return type is a string."
+
argtypes = [GEOM_PTR]
restype = geos_char_p
errcheck = staticmethod(check_string)
diff --git a/django/contrib/gis/geos/prototypes/misc.py b/django/contrib/gis/geos/prototypes/misc.py
index bd5859e79b..a59186976b 100644
--- a/django/contrib/gis/geos/prototypes/misc.py
+++ b/django/contrib/gis/geos/prototypes/misc.py
@@ -1,6 +1,6 @@
"""
- This module is for the miscellaneous GEOS routines, particularly the
- ones that return the area, distance, and length.
+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
diff --git a/django/contrib/gis/geos/prototypes/predicates.py b/django/contrib/gis/geos/prototypes/predicates.py
index dd07cbfb26..71cfd8d94b 100644
--- a/django/contrib/gis/geos/prototypes/predicates.py
+++ b/django/contrib/gis/geos/prototypes/predicates.py
@@ -1,6 +1,6 @@
"""
- This module houses the GEOS ctypes prototype functions for the
- unary and binary predicate operations on geometries.
+This module houses the GEOS ctypes prototype functions for the
+unary and binary predicate operations on geometries.
"""
from ctypes import c_byte, c_char_p, c_double
@@ -12,6 +12,7 @@ from django.contrib.gis.geos.prototypes.errcheck import check_predicate
# ## Binary & unary predicate factories ##
class UnaryPredicate(GEOSFuncFactory):
"For GEOS unary predicate functions."
+
argtypes = [GEOM_PTR]
restype = c_byte
errcheck = staticmethod(check_predicate)
@@ -19,6 +20,7 @@ class UnaryPredicate(GEOSFuncFactory):
class BinaryPredicate(UnaryPredicate):
"For GEOS binary predicate functions."
+
argtypes = [GEOM_PTR, GEOM_PTR]
diff --git a/django/contrib/gis/geos/prototypes/topology.py b/django/contrib/gis/geos/prototypes/topology.py
index 9323bb2d16..541c954c02 100644
--- a/django/contrib/gis/geos/prototypes/topology.py
+++ b/django/contrib/gis/geos/prototypes/topology.py
@@ -1,6 +1,6 @@
"""
- This module houses the GEOS ctypes prototype functions for the
- topological operations on geometries.
+This module houses the GEOS ctypes prototype functions for the
+topological operations on geometries.
"""
from ctypes import c_double, c_int
@@ -16,6 +16,7 @@ from django.contrib.gis.geos.prototypes.geom import geos_char_p
class Topology(GEOSFuncFactory):
"For GEOS unary topology functions."
+
argtypes = [GEOM_PTR]
restype = GEOM_PTR
errcheck = staticmethod(check_geom)
diff --git a/django/contrib/gis/utils/__init__.py b/django/contrib/gis/utils/__init__.py
index f42fa90226..92ff64dee7 100644
--- a/django/contrib/gis/utils/__init__.py
+++ b/django/contrib/gis/utils/__init__.py
@@ -1,5 +1,5 @@
"""
- This module contains useful utilities for GeoDjango.
+This module contains useful utilities for GeoDjango.
"""
from django.contrib.gis.utils.ogrinfo import ogrinfo
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index d1fe7c5721..137dd6b7f7 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -1,10 +1,10 @@
# LayerMapping -- A Django Model/OGR Layer Mapping Utility
"""
- The LayerMapping class provides a way to map the contents of OGR
- vector files (e.g. SHP files) to Geographic-enabled Django models.
+The LayerMapping class provides a way to map the contents of OGR
+vector files (e.g. SHP files) to Geographic-enabled Django models.
- For more information, please consult the GeoDjango documentation:
- https://docs.djangoproject.com/en/dev/ref/contrib/gis/layermapping/
+For more information, please consult the GeoDjango documentation:
+ https://docs.djangoproject.com/en/dev/ref/contrib/gis/layermapping/
"""
import sys
from decimal import Decimal
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py
index 09b0a5f9c8..1111fdb41f 100644
--- a/django/core/cache/backends/base.py
+++ b/django/core/cache/backends/base.py
@@ -1,4 +1,5 @@
"Base Cache class."
+
import time
import warnings
diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
index f41105177f..2dd847c903 100644
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -1,4 +1,5 @@
"Database cache backend."
+
import base64
import pickle
from datetime import datetime, timezone
diff --git a/django/core/cache/backends/filebased.py b/django/core/cache/backends/filebased.py
index cbf47e4e16..862a8b57d9 100644
--- a/django/core/cache/backends/filebased.py
+++ b/django/core/cache/backends/filebased.py
@@ -1,4 +1,5 @@
"File-based cache backend"
+
import glob
import os
import pickle
diff --git a/django/core/cache/backends/locmem.py b/django/core/cache/backends/locmem.py
index cbc8dba51e..b62fedbbd9 100644
--- a/django/core/cache/backends/locmem.py
+++ b/django/core/cache/backends/locmem.py
@@ -1,4 +1,5 @@
"Thread-safe in-memory cache backend."
+
import pickle
import time
from collections import OrderedDict
diff --git a/django/forms/forms.py b/django/forms/forms.py
index 844f15f9f2..d05bf4bb9e 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -431,6 +431,7 @@ class BaseForm(RenderableFormMixin):
class Form(BaseForm, metaclass=DeclarativeFieldsMetaclass):
"A collection of Fields, plus their associated data."
+
# This is a separate class from BaseForm in order to abstract the way
# self.fields is specified. This class (Form) is the one that does the
# fancy metaclass stuff purely for the semantic sugar -- it allows one
diff --git a/django/template/context.py b/django/template/context.py
index 90825fcdb5..bacce88173 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -7,6 +7,7 @@ _builtin_context_processors = ("django.template.context_processors.csrf",)
class ContextPopException(Exception):
"pop() has been called more times than push()"
+
pass
diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py
index 812505de82..a20130bb02 100644
--- a/tests/admin_views/models.py
+++ b/tests/admin_views/models.py
@@ -546,6 +546,7 @@ class SuperVillain(Villain):
class FunkyTag(models.Model):
"Because we all know there's only one real use case for GFKs."
+
name = models.CharField(max_length=25)
content_type = models.ForeignKey(ContentType, models.CASCADE)
object_id = models.PositiveIntegerField()
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 2b14238f21..3be344f9e5 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -7159,7 +7159,7 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase):
url = reverse("admin:admin_views_pizza_change", args=(pizza.pk,))
with self.settings(LANGUAGE_CODE="fr"):
response = self.client.get(url)
- self.assertContains(response, "<label>Toppings\u00A0:</label>", html=True)
+ self.assertContains(response, "<label>Toppings\u00a0:</label>", html=True)
@override_settings(ROOT_URLCONF="admin_views.urls")
diff --git a/tests/auth_tests/test_validators.py b/tests/auth_tests/test_validators.py
index d6ee44511d..ea75c4a080 100644
--- a/tests/auth_tests/test_validators.py
+++ b/tests/auth_tests/test_validators.py
@@ -350,10 +350,10 @@ class UsernameValidatorsTests(SimpleTestCase):
invalid_usernames = [
"o'connell",
"عبد ال",
- "zerowidth\u200Bspace",
- "nonbreaking\u00A0space",
+ "zerowidth\u200bspace",
+ "nonbreaking\u00a0space",
"en\u2013dash",
- "trailingnewline\u000A",
+ "trailingnewline\u000a",
]
v = validators.UnicodeUsernameValidator()
for valid in valid_usernames:
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index d0af6e49f0..b955e8aad4 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -90,7 +90,7 @@ class LastExecutedQueryTest(TestCase):
def test_query_encoding(self):
"""last_executed_query() returns a string."""
- data = RawData.objects.filter(raw_data=b"\x00\x46 \xFE").extra(
+ data = RawData.objects.filter(raw_data=b"\x00\x46 \xfe").extra(
select={"föö": 1}
)
sql, params = data.query.sql_with_params()
diff --git a/tests/forms_tests/tests/test_utils.py b/tests/forms_tests/tests/test_utils.py
index a50f86c934..b8fbadc2b8 100644
--- a/tests/forms_tests/tests/test_utils.py
+++ b/tests/forms_tests/tests/test_utils.py
@@ -73,7 +73,7 @@ class FormsUtilsTestCase(SimpleTestCase):
)
# Can take a Unicode string.
self.assertHTMLEqual(
- str(ErrorList(ValidationError("Not \u03C0.").messages)),
+ str(ErrorList(ValidationError("Not \u03c0.").messages)),
'<ul class="errorlist"><li>Not π.</li></ul>',
)
# Can take a lazy string.
@@ -107,7 +107,7 @@ class FormsUtilsTestCase(SimpleTestCase):
ValidationError(
[
"1. First error.",
- "2. Not \u03C0.",
+ "2. Not \u03c0.",
gettext_lazy("3. Error."),
{
"error_1": "4. First dict error.",
diff --git a/tests/gis_tests/distapp/models.py b/tests/gis_tests/distapp/models.py
index b7b60ebf38..ff0045b82e 100644
--- a/tests/gis_tests/distapp/models.py
+++ b/tests/gis_tests/distapp/models.py
@@ -15,17 +15,20 @@ class NamedModel(models.Model):
class SouthTexasCity(NamedModel):
"City model on projected coordinate system for South Texas."
+
point = models.PointField(srid=32140)
radius = models.IntegerField(default=10000)
class SouthTexasCityFt(NamedModel):
"Same City model as above, but U.S. survey feet are the units."
+
point = models.PointField(srid=2278)
class AustraliaCity(NamedModel):
"City model for Australia, using WGS84."
+
point = models.PointField()
radius = models.IntegerField(default=10000)
allowed_distance = models.FloatField(default=0.5)
@@ -34,19 +37,23 @@ class AustraliaCity(NamedModel):
class CensusZipcode(NamedModel):
"Model for a few South Texas ZIP codes (in original Census NAD83)."
+
poly = models.PolygonField(srid=4269)
class SouthTexasZipcode(NamedModel):
"Model for a few South Texas ZIP codes."
+
poly = models.PolygonField(srid=32140, null=gisfield_may_be_null)
class Interstate(NamedModel):
"Geodetic model for U.S. Interstates."
+
path = models.LineStringField()
class SouthTexasInterstate(NamedModel):
"Projected model for South Texas Interstates."
+
path = models.LineStringField(srid=32140)
diff --git a/tests/model_fields/test_binaryfield.py b/tests/model_fields/test_binaryfield.py
index 05ebce3aab..9d89fdff0b 100644
--- a/tests/model_fields/test_binaryfield.py
+++ b/tests/model_fields/test_binaryfield.py
@@ -6,7 +6,7 @@ from .models import DataModel
class BinaryFieldTests(TestCase):
- binary_data = b"\x00\x46\xFE"
+ binary_data = b"\x00\x46\xfe"
def test_set_and_retrieve(self):
data_set = (
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py
index ab5bf2bab1..2cc3de5f4d 100644
--- a/tests/postgres_tests/test_constraints.py
+++ b/tests/postgres_tests/test_constraints.py
@@ -309,7 +309,7 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
def test_invalid_expressions(self):
msg = "The expressions must be a list of 2-tuples."
- for expressions in (["foo"], [("foo")], [("foo_1", "foo_2", "foo_3")]):
+ for expressions in (["foo"], ["foo"], [("foo_1", "foo_2", "foo_3")]):
with self.subTest(expressions), self.assertRaisesMessage(ValueError, msg):
ExclusionConstraint(
index_type="GIST",
diff --git a/tests/serializers/test_data.py b/tests/serializers/test_data.py
index bd81ce0c14..6a6de18033 100644
--- a/tests/serializers/test_data.py
+++ b/tests/serializers/test_data.py
@@ -257,7 +257,7 @@ uuid_obj = uuid.uuid4()
test_data = [
# Format: (test helper, PK value, Model Class, data)
- (data_obj, 1, BinaryData, memoryview(b"\x05\xFD\x00")),
+ (data_obj, 1, BinaryData, memoryview(b"\x05\xfd\x00")),
(data_obj, 5, BooleanData, True),
(data_obj, 6, BooleanData, False),
(data_obj, 7, BooleanData, None),
diff --git a/tests/serializers/test_xml.py b/tests/serializers/test_xml.py
index c9df2f2a5b..0ae66f77d0 100644
--- a/tests/serializers/test_xml.py
+++ b/tests/serializers/test_xml.py
@@ -70,7 +70,7 @@ class XmlSerializerTestCase(SerializersTestBase, TestCase):
msg = "Article.headline (pk:%s) contains unserializable characters" % self.a1.pk
with self.assertRaisesMessage(ValueError, msg):
serializers.serialize(self.serializer_name, [self.a1])
- self.a1.headline = "HT \u0009, LF \u000A, and CR \u000D are allowed"
+ self.a1.headline = "HT \u0009, LF \u000a, and CR \u000d are allowed"
self.assertIn(
"HT \t, LF \n, and CR \r are allowed",
serializers.serialize(self.serializer_name, [self.a1]),
diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py
index ab2cfb3f7c..63c7889cbc 100644
--- a/tests/utils_tests/test_text.py
+++ b/tests/utils_tests/test_text.py
@@ -9,7 +9,7 @@ from django.utils.functional import lazystr
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy, override
-IS_WIDE_BUILD = len("\U0001F4A9") == 1
+IS_WIDE_BUILD = len("\U0001f4a9") == 1
class TestUtilsText(SimpleTestCase):
@@ -76,16 +76,16 @@ class TestUtilsText(SimpleTestCase):
# Ensure the final length is calculated correctly when there are
# combining characters with no precomposed form, and that combining
# characters are not split up.
- truncator = text.Truncator("-B\u030AB\u030A----8")
- self.assertEqual("-B\u030A…", truncator.chars(3))
- self.assertEqual("-B\u030AB\u030A-…", truncator.chars(5))
- self.assertEqual("-B\u030AB\u030A----8", truncator.chars(8))
+ truncator = text.Truncator("-B\u030aB\u030a----8")
+ self.assertEqual("-B\u030a…", truncator.chars(3))
+ self.assertEqual("-B\u030aB\u030a-…", truncator.chars(5))
+ self.assertEqual("-B\u030aB\u030a----8", truncator.chars(8))
# Ensure the length of the end text is correctly calculated when it
# contains combining characters with no precomposed form.
truncator = text.Truncator("-----")
- self.assertEqual("---B\u030A", truncator.chars(4, "B\u030A"))
- self.assertEqual("-----", truncator.chars(5, "B\u030A"))
+ self.assertEqual("---B\u030a", truncator.chars(4, "B\u030a"))
+ self.assertEqual("-----", truncator.chars(5, "B\u030a"))
# Make a best effort to shorten to the desired length, but requesting
# a length shorter than the ellipsis shouldn't break