From c24b7bee6c1715618f7872a3436038a1a8c34aa3 Mon Sep 17 00:00:00 2001 From: Thibaut Decombe Date: Fri, 10 Nov 2023 11:01:57 +0100 Subject: [PATCH] Fix last occurences and reorder allowlist --- .../contrib/gis/db/backends/postgis/operations.pyi | 6 ++++-- django-stubs/contrib/gis/db/models/functions.pyi | 10 +++++----- scripts/stubtest/allowlist.txt | 11 +++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/django-stubs/contrib/gis/db/backends/postgis/operations.pyi b/django-stubs/contrib/gis/db/backends/postgis/operations.pyi index adeb6ca00..eee045678 100644 --- a/django-stubs/contrib/gis/db/backends/postgis/operations.pyi +++ b/django-stubs/contrib/gis/db/backends/postgis/operations.pyi @@ -2,8 +2,10 @@ from typing import Any, Literal from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations from django.contrib.gis.db.backends.utils import SpatialOperator +from django.contrib.gis.db.models.fields import GeometryField from django.db.backends.postgresql.operations import DatabaseOperations from django.db.models import Func +from django.utils.functional import cached_property BILATERAL: Literal["bilateral"] @@ -16,8 +18,8 @@ class PostGISOperator(SpatialOperator): class ST_Polygon(Func): function: str def __init__(self, expr: Any) -> None: ... - @property - def output_field(self) -> Any: ... + @cached_property + def output_field(self) -> GeometryField: ... class PostGISOperations(BaseSpatialOperations, DatabaseOperations): name: str diff --git a/django-stubs/contrib/gis/db/models/functions.pyi b/django-stubs/contrib/gis/db/models/functions.pyi index 38b592798..2a4f380ca 100644 --- a/django-stubs/contrib/gis/db/models/functions.pyi +++ b/django-stubs/contrib/gis/db/models/functions.pyi @@ -1,7 +1,7 @@ from typing import Any, ClassVar from django.contrib.gis.db.models.fields import GeometryField -from django.contrib.gis.db.models.sql.conversion import DistanceField +from django.contrib.gis.db.models.sql.conversion import AreaField, DistanceField from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import BinaryField, BooleanField, FloatField, Func, IntegerField, TextField from django.db.models import Transform as StandardTransform @@ -18,8 +18,8 @@ class GeoFuncMixin: class GeoFunc(GeoFuncMixin, Func): ... class GeomOutputGeoFunc(GeoFunc): - @property - def output_field(self) -> Any: ... + @cached_property + def output_field(self) -> GeometryField: ... class SQLiteDecimalToFloatMixin: def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... @@ -30,8 +30,8 @@ class OracleToleranceMixin: class Area(OracleToleranceMixin, GeoFunc): arity: int - @property - def output_field(self) -> Any: ... + @cached_property + def output_field(self) -> AreaField: ... def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ... class Azimuth(GeoFunc): diff --git a/scripts/stubtest/allowlist.txt b/scripts/stubtest/allowlist.txt index 74c035e3a..40376cb50 100644 --- a/scripts/stubtest/allowlist.txt +++ b/scripts/stubtest/allowlist.txt @@ -172,6 +172,7 @@ django.contrib.gis.db.backends.mysql.operations.MySQLOperations.mariadb django.contrib.gis.db.backends.mysql.operations.MySQLOperations.mysql django.contrib.gis.db.backends.mysql.operations.MySQLOperations.select django.contrib.gis.db.backends.mysql.operations.MySQLOperations.unsupported_functions +django.contrib.gis.db.backends.postgis.operations.ST_Polygon.output_field django.contrib.gis.db.backends.spatialite.features.DatabaseFeatures.supports_area_geodetic django.contrib.gis.db.backends.spatialite.operations.SpatiaLiteOperations.unsupported_functions django.contrib.gis.db.models.DecimalField.validators @@ -191,6 +192,10 @@ django.contrib.gis.db.models.ForeignObjectRel.related_model django.contrib.gis.db.models.IntegerField.validators django.contrib.gis.db.models.Lookup.contains_aggregate django.contrib.gis.db.models.Lookup.contains_over_clause +django.contrib.gis.db.models.aggregates.GeoAggregate.output_field +django.contrib.gis.db.models.functions.Area.output_field +django.contrib.gis.db.models.functions.DistanceResultMixin.output_field +django.contrib.gis.db.models.functions.GeomOutputGeoFunc.output_field django.contrib.gis.forms.BaseForm.changed_data django.contrib.gis.forms.BaseFormSet.forms django.contrib.gis.forms.BaseFormSet.management_form @@ -305,9 +310,10 @@ django.db.models.Lookup.contains_aggregate django.db.models.Lookup.contains_over_clause django.db.models.expressions.BaseExpression.contains_aggregate django.db.models.expressions.BaseExpression.contains_column_references -django.db.models.expressions.BaseExpression.contains_subquery django.db.models.expressions.BaseExpression.contains_over_clause +django.db.models.expressions.BaseExpression.contains_subquery django.db.models.expressions.BaseExpression.convert_value +django.db.models.expressions.BaseExpression.output_field django.db.models.fields.DecimalField.validators django.db.models.fields.Field.cached_col django.db.models.fields.Field.validators @@ -390,6 +396,3 @@ django.urls.resolvers.URLPattern.lookup_str django.urls.resolvers.URLResolver.url_patterns django.urls.resolvers.URLResolver.urlconf_module django.utils.connection.BaseConnectionHandler.settings -django.contrib.gis.db.models.aggregates.GeoAggregate.output_field -django.contrib.gis.db.models.functions.DistanceResultMixin.output_field -django.db.models.expressions.BaseExpression.output_field