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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions django-stubs/contrib/gis/db/models/functions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ class GeoFuncMixin:
def name(self) -> str: ...
@cached_property
def geo_field(self) -> Any: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: BaseDatabaseWrapper,
function: str | None = None,
**extra_context: Any,
) -> _AsSqlType: ...
def resolve_expression(
self,
*args: Any,
**kwargs: Any,
) -> Any: ...

class GeoFunc(GeoFuncMixin, Func): ...
class GeoFunc(GeoFuncMixin, Func): # type: ignore[misc]
...

class GeomOutputGeoFunc(GeoFunc):
@cached_property
Expand All @@ -46,6 +54,10 @@ class Area(OracleToleranceMixin, GeoFunc):
@override
def output_field(self) -> AreaField: ...
@override
def as_sql( # type: ignore[override]
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any
) -> _AsSqlType: ...
@override
def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ...

class Azimuth(GeoFunc):
Expand Down Expand Up @@ -82,19 +94,19 @@ class AsWKT(GeoFunc):
output_field: ClassVar[TextField]
arity: int

class BoundingCircle(OracleToleranceMixin, GeomOutputGeoFunc):
class BoundingCircle(OracleToleranceMixin, GeomOutputGeoFunc): # type: ignore[misc]
def __init__(self, expression: Any, num_seg: int = 48, **extra: Any) -> None: ...
@override
def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ...

class Centroid(OracleToleranceMixin, GeomOutputGeoFunc):
class Centroid(OracleToleranceMixin, GeomOutputGeoFunc): # type: ignore[misc]
arity: int

class ClosestPoint(GeomOutputGeoFunc):
arity: int
geom_param_pos: tuple[int, int]

class Difference(OracleToleranceMixin, GeomOutputGeoFunc):
class Difference(OracleToleranceMixin, GeomOutputGeoFunc): # type: ignore[misc]
arity: int
geom_param_pos: Any

Expand All @@ -103,7 +115,7 @@ class DistanceResultMixin:
def output_field(self) -> DistanceField: ...
def source_is_geography(self) -> Any: ...

class Distance(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
class Distance(DistanceResultMixin, OracleToleranceMixin, GeoFunc): # type: ignore[misc]
geom_param_pos: Any
spheroid: Any
def __init__(self, expr1: Any, expr2: Any, spheroid: Any | None = None, **extra: Any) -> None: ...
Expand Down Expand Up @@ -138,20 +150,20 @@ class GeometryDistance(GeoFunc):
arg_joiner: str
geom_param_pos: Any

class Intersection(OracleToleranceMixin, GeomOutputGeoFunc):
class Intersection(OracleToleranceMixin, GeomOutputGeoFunc): # type: ignore[misc]
arity: int
geom_param_pos: Any

class GeometryType(GeoFuncMixin, StandardTransform):
class GeometryType(GeoFuncMixin, StandardTransform): # type: ignore[misc]
lookup_name: str
output_field: ClassVar[CharField]
def as_oracle(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ...

class IsEmpty(GeoFuncMixin, StandardTransform):
class IsEmpty(GeoFuncMixin, StandardTransform): # type: ignore[misc]
lookup_name: str
output_field: ClassVar[BooleanField]

class IsValid(OracleToleranceMixin, GeoFuncMixin, StandardTransform):
class IsValid(OracleToleranceMixin, GeoFuncMixin, StandardTransform): # type: ignore[misc]
lookup_name: str
output_field: ClassVar[BooleanField]
@override
Expand All @@ -160,6 +172,10 @@ class IsValid(OracleToleranceMixin, GeoFuncMixin, StandardTransform):
class Length(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
spheroid: Any
def __init__(self, expr1: Any, spheroid: bool = True, **extra: Any) -> None: ...
@override
def as_sql( # type: ignore[override]
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any
) -> _AsSqlType: ...
def as_postgresql(
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any
) -> _AsSqlType: ...
Expand All @@ -185,15 +201,15 @@ class NumPoints(GeoFunc):
output_field: ClassVar[IntegerField]
arity: int

class Perimeter(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
class Perimeter(DistanceResultMixin, OracleToleranceMixin, GeoFunc): # type: ignore[misc]
arity: int
def as_postgresql(
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any
) -> _AsSqlType: ...
@override
def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ...

class PointOnSurface(OracleToleranceMixin, GeomOutputGeoFunc):
class PointOnSurface(OracleToleranceMixin, GeomOutputGeoFunc): # type: ignore[misc]
arity: int

class Reverse(GeoFunc):
Expand All @@ -202,13 +218,13 @@ class Reverse(GeoFunc):
class Rotate(GeomOutputGeoFunc):
def __init__(self, expression: Any, angle: Any, origin: Any | None = None, **extra: Any) -> None: ...

class Scale(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc):
class Scale(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc): # type: ignore[misc]
def __init__(self, expression: Any, x: Any, y: Any, z: float = 0.0, **extra: Any) -> None: ...

class SnapToGrid(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc):
class SnapToGrid(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc): # type: ignore[misc]
def __init__(self, expression: Any, *args: Any, **extra: Any) -> None: ...

class SymDifference(OracleToleranceMixin, GeomOutputGeoFunc):
class SymDifference(OracleToleranceMixin, GeomOutputGeoFunc): # type: ignore[misc]
arity: int
geom_param_pos: Any

Expand All @@ -219,6 +235,6 @@ class Translate(Scale):
@override
def as_sqlite(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper, **extra_context: Any) -> _AsSqlType: ...

class Union(OracleToleranceMixin, GeomOutputGeoFunc):
class Union(OracleToleranceMixin, GeomOutputGeoFunc): # type: ignore[misc]
arity: int
geom_param_pos: Any
6 changes: 5 additions & 1 deletion django-stubs/contrib/gis/db/models/lookups.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from typing import Any

from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.models import Lookup, Transform
from django.db.models.sql.compiler import SQLCompiler, _AsSqlType
from typing_extensions import override

class RasterBandTransform(Transform): ...
class RasterBandTransform(Transform):
@override
def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ... # type: ignore[override]

class GISLookup(Lookup):
sql_template: Any
Expand Down
4 changes: 0 additions & 4 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ django.contrib.gis.admin.site
django.contrib.gis.db.backends.spatialite.base.DatabaseWrapper.ops
django.contrib.gis.db.models.CharField.description
django.contrib.gis.db.models.Field.description
django.contrib.gis.db.models.functions.Area.as_sql
django.contrib.gis.db.models.functions.GeoFuncMixin.as_sql
django.contrib.gis.db.models.functions.Length.as_sql
django.contrib.gis.db.models.lookups.RasterBandTransform.as_sql
django.contrib.gis.forms.inlineformset_factory
django.contrib.gis.forms.modelformset_factory
django.contrib.redirects.models.Redirect.id
Expand Down
Loading