From 8ee3af33ea15637f1cce153bcf751c41a8948b0f Mon Sep 17 00:00:00 2001 From: Taku Fukada Date: Sun, 25 Dec 2022 14:17:08 +0900 Subject: [PATCH 1/6] Fix missing imports in gis/**/__init__.pyi --- django-stubs/contrib/gis/admin/__init__.pyi | 3 +++ django-stubs/contrib/gis/db/models/sql/__init__.pyi | 2 ++ django-stubs/contrib/gis/forms/__init__.pyi | 13 +++++++++++++ django-stubs/contrib/gis/geos/__init__.pyi | 2 ++ django-stubs/contrib/gis/utils/__init__.pyi | 8 ++++++-- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/django-stubs/contrib/gis/admin/__init__.pyi b/django-stubs/contrib/gis/admin/__init__.pyi index a9b32c9ea..94ead5db7 100644 --- a/django-stubs/contrib/gis/admin/__init__.pyi +++ b/django-stubs/contrib/gis/admin/__init__.pyi @@ -4,8 +4,11 @@ from django.contrib.admin import AdminSite as AdminSite from django.contrib.admin import ModelAdmin as ModelAdmin from django.contrib.admin import StackedInline as StackedInline from django.contrib.admin import TabularInline as TabularInline +from django.contrib.admin import action as action from django.contrib.admin import autodiscover as autodiscover from django.contrib.admin import register as register from django.contrib.admin import site as site from django.contrib.gis.admin.options import GeoModelAdmin as GeoModelAdmin +from django.contrib.gis.admin.options import GISModelAdmin as GISModelAdmin from django.contrib.gis.admin.options import OSMGeoAdmin as OSMGeoAdmin +from django.contrib.gis.admin.widgets import OpenLayersWidget as OpenLayersWidget diff --git a/django-stubs/contrib/gis/db/models/sql/__init__.pyi b/django-stubs/contrib/gis/db/models/sql/__init__.pyi index e69de29bb..ab0a35c68 100644 --- a/django-stubs/contrib/gis/db/models/sql/__init__.pyi +++ b/django-stubs/contrib/gis/db/models/sql/__init__.pyi @@ -0,0 +1,2 @@ +from django.contrib.gis.db.models.sql.conversion import AreaField as AreaField +from django.contrib.gis.db.models.sql.conversion import DistanceField as DistanceField diff --git a/django-stubs/contrib/gis/forms/__init__.pyi b/django-stubs/contrib/gis/forms/__init__.pyi index e69de29bb..e12a01bd7 100644 --- a/django-stubs/contrib/gis/forms/__init__.pyi +++ b/django-stubs/contrib/gis/forms/__init__.pyi @@ -0,0 +1,13 @@ +from django.forms import * + +from .fields import GeometryCollectionField as GeometryCollectionField +from .fields import GeometryField as GeometryField +from .fields import LineStringField as LineStringField +from .fields import MultiLineStringField as MultiLineStringField +from .fields import MultiPointField as MultiPointField +from .fields import MultiPolygonField as MultiPolygonField +from .fields import PointField as PointField +from .fields import PolygonField as PolygonField +from .widgets import BaseGeometryWidget as BaseGeometryWidget +from .widgets import OpenLayersWidget as OpenLayersWidget +from .widgets import OSMWidget as OSMWidget diff --git a/django-stubs/contrib/gis/geos/__init__.pyi b/django-stubs/contrib/gis/geos/__init__.pyi index 462c21f40..3be5847b1 100644 --- a/django-stubs/contrib/gis/geos/__init__.pyi +++ b/django-stubs/contrib/gis/geos/__init__.pyi @@ -2,6 +2,7 @@ from .collections import GeometryCollection as GeometryCollection from .collections import MultiLineString as MultiLineString from .collections import MultiPoint as MultiPoint from .collections import MultiPolygon as MultiPolygon +from .error import GEOSException as GEOSException from .factory import fromfile as fromfile from .factory import fromstr as fromstr from .geometry import GEOSGeometry as GEOSGeometry @@ -11,6 +12,7 @@ from .io import WKBReader as WKBReader from .io import WKBWriter as WKBWriter from .io import WKTReader as WKTReader from .io import WKTWriter as WKTWriter +from .libgeos import geos_version as geos_version from .linestring import LinearRing as LinearRing from .linestring import LineString as LineString from .point import Point as Point diff --git a/django-stubs/contrib/gis/utils/__init__.pyi b/django-stubs/contrib/gis/utils/__init__.pyi index 6eadf153d..833d3c7e1 100644 --- a/django-stubs/contrib/gis/utils/__init__.pyi +++ b/django-stubs/contrib/gis/utils/__init__.pyi @@ -1,2 +1,6 @@ -from django.contrib.gis.utils.layermapping import LayerMapError, LayerMapping -from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect +from django.contrib.gis.utils.layermapping import LayerMapError as LayerMapError +from django.contrib.gis.utils.layermapping import LayerMapping as LayerMapping +from django.contrib.gis.utils.ogrinfo import ogrinfo as ogrinfo +from django.contrib.gis.utils.ogrinspect import mapping as mapping +from django.contrib.gis.utils.ogrinspect import ogrinspect as ogrinspect +from django.contrib.gis.utils.srs import add_srs_entry as add_srs_entry From 976fb5055c7d8bfc2ec7a1673a3f223591c88d93 Mon Sep 17 00:00:00 2001 From: Taku Fukada Date: Sun, 25 Dec 2022 14:18:58 +0900 Subject: [PATCH 2/6] Improve type-hints for GeoDjango --- django-stubs/contrib/gis/admin/options.pyi | 5 + django-stubs/contrib/gis/apps.pyi | 7 +- django-stubs/contrib/gis/db/models/fields.pyi | 70 ++++---- django-stubs/contrib/gis/feeds.pyi | 26 +-- django-stubs/contrib/gis/gdal/datasource.pyi | 12 +- django-stubs/contrib/gis/gdal/driver.pyi | 4 +- django-stubs/contrib/gis/gdal/envelope.pyi | 18 +- django-stubs/contrib/gis/gdal/feature.pyi | 23 +-- django-stubs/contrib/gis/gdal/field.pyi | 20 +-- django-stubs/contrib/gis/gdal/geometries.pyi | 149 ++++++++-------- django-stubs/contrib/gis/gdal/geomtype.pyi | 6 +- django-stubs/contrib/gis/gdal/layer.pyi | 45 +++-- django-stubs/contrib/gis/gdal/libgdal.pyi | 12 +- django-stubs/contrib/gis/gdal/raster/band.pyi | 40 +++-- .../contrib/gis/gdal/raster/const.pyi | 12 +- .../contrib/gis/gdal/raster/source.pyi | 59 ++++--- django-stubs/contrib/gis/gdal/srs.pyi | 63 +++---- django-stubs/contrib/gis/geoip2/base.pyi | 30 ++-- django-stubs/contrib/gis/geometry.pyi | 8 +- django-stubs/contrib/gis/geos/base.pyi | 5 +- django-stubs/contrib/gis/geos/collections.pyi | 8 +- django-stubs/contrib/gis/geos/coordseq.pyi | 37 ++-- django-stubs/contrib/gis/geos/factory.pyi | 8 +- django-stubs/contrib/gis/geos/geometry.pyi | 159 +++++++++--------- django-stubs/contrib/gis/geos/io.pyi | 5 +- django-stubs/contrib/gis/geos/libgeos.pyi | 4 +- django-stubs/contrib/gis/geos/linestring.pyi | 8 +- .../contrib/gis/geos/mutable_list.pyi | 20 +-- django-stubs/contrib/gis/geos/point.pyi | 18 +- django-stubs/contrib/gis/geos/polygon.pyi | 17 +- django-stubs/contrib/gis/geos/prepared.pyi | 19 ++- django-stubs/contrib/gis/measure.pyi | 49 +++--- django-stubs/contrib/gis/shortcuts.pyi | 8 +- .../contrib/gis/utils/layermapping.pyi | 46 ++--- django-stubs/contrib/gis/utils/ogrinfo.pyi | 4 +- django-stubs/contrib/gis/utils/ogrinspect.pyi | 8 +- 36 files changed, 538 insertions(+), 494 deletions(-) diff --git a/django-stubs/contrib/gis/admin/options.pyi b/django-stubs/contrib/gis/admin/options.pyi index f343ff678..34ebd9ecc 100644 --- a/django-stubs/contrib/gis/admin/options.pyi +++ b/django-stubs/contrib/gis/admin/options.pyi @@ -1,9 +1,14 @@ from typing import Any from django.contrib.admin import ModelAdmin as ModelAdmin +from django.contrib.gis.forms import BaseGeometryWidget spherical_mercator_srid: int +class GISModelAdmin(ModelAdmin): + gis_widget: BaseGeometryWidget + gis_widget_kwargs: dict[str, Any] + class GeoModelAdmin(ModelAdmin): default_lon: int default_lat: int diff --git a/django-stubs/contrib/gis/apps.pyi b/django-stubs/contrib/gis/apps.pyi index 95b1afb4a..a169c0be3 100644 --- a/django-stubs/contrib/gis/apps.pyi +++ b/django-stubs/contrib/gis/apps.pyi @@ -1,8 +1,3 @@ -from typing import Any - from django.apps import AppConfig as AppConfig -class GISConfig(AppConfig): - name: str - verbose_name: Any - def ready(self) -> None: ... +class GISConfig(AppConfig): ... diff --git a/django-stubs/contrib/gis/db/models/fields.pyi b/django-stubs/contrib/gis/db/models/fields.pyi index 736aa3f5f..98e55f9d0 100644 --- a/django-stubs/contrib/gis/db/models/fields.pyi +++ b/django-stubs/contrib/gis/db/models/fields.pyi @@ -1,6 +1,17 @@ from collections.abc import Iterable from typing import Any, NamedTuple, TypeVar +from django.contrib.gis import forms +from django.contrib.gis.geos import ( + GeometryCollection, + GEOSGeometry, + LineString, + MultiLineString, + MultiPoint, + MultiPolygon, + Point, + Polygon, +) from django.core.validators import _ValidatorCallable from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices from django.utils.functional import _StrOrPromise @@ -19,6 +30,12 @@ class SRIDCacheEntry(NamedTuple): def get_srid_info(srid: int, connection: Any) -> SRIDCacheEntry: ... class BaseSpatialField(Field[_ST, _GT]): + form_class: type[forms.GeometryField] + geom_type: str + geom_class: type[GEOSGeometry] | None + geography: bool + spatial_index: bool + srid: int def __init__( self, verbose_name: _StrOrPromise | None = ..., @@ -59,12 +76,7 @@ class BaseSpatialField(Field[_ST, _GT]): def get_prep_value(self, value: Any) -> Any: ... class GeometryField(BaseSpatialField): - description: Any - form_class: Any - geom_type: str - geom_class: Any - dim: Any - geography: Any + dim: int def __init__( self, verbose_name: _StrOrPromise | None = ..., @@ -101,56 +113,38 @@ class GeometryField(BaseSpatialField): def select_format(self, compiler: Any, sql: Any, params: Any) -> Any: ... class PointField(GeometryField): - geom_type: str - geom_class: Any - form_class: Any - description: Any + geom_class: type[Point] + form_class: type[forms.PointField] class LineStringField(GeometryField): - geom_type: str - geom_class: Any - form_class: Any - description: Any + geom_class: type[LineString] + form_class: type[forms.LineStringField] class PolygonField(GeometryField): - geom_type: str - geom_class: Any - form_class: Any - description: Any + geom_class: type[Polygon] + form_class: type[forms.PolygonField] class MultiPointField(GeometryField): - geom_type: str - geom_class: Any - form_class: Any - description: Any + geom_class: type[MultiPoint] + form_class: type[forms.MultiPointField] class MultiLineStringField(GeometryField): - geom_type: str - geom_class: Any - form_class: Any - description: Any + geom_class: type[MultiLineString] + form_class: type[forms.MultiLineStringField] class MultiPolygonField(GeometryField): - geom_type: str - geom_class: Any - form_class: Any - description: Any + geom_class: type[MultiPolygon] + form_class: type[forms.MultiPolygonField] class GeometryCollectionField(GeometryField): - geom_type: str - geom_class: Any - form_class: Any - description: Any + geom_class: type[GeometryCollection] + form_class: type[forms.GeometryCollectionField] class ExtentField(Field): - description: Any def get_internal_type(self) -> Any: ... def select_format(self, compiler: Any, sql: Any, params: Any) -> Any: ... class RasterField(BaseSpatialField): - description: Any - geom_type: str - geography: bool def db_type(self, connection: Any) -> Any: ... def from_db_value(self, value: Any, expression: Any, connection: Any) -> Any: ... def get_transform(self, name: Any) -> Any: ... diff --git a/django-stubs/contrib/gis/feeds.pyi b/django-stubs/contrib/gis/feeds.pyi index d3ecee6d8..b5274bf7f 100644 --- a/django-stubs/contrib/gis/feeds.pyi +++ b/django-stubs/contrib/gis/feeds.pyi @@ -1,29 +1,21 @@ +from collections.abc import Iterable, Sequence from typing import Any from django.contrib.syndication.views import Feed as BaseFeed from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed +from django.utils.xmlutils import SimplerXMLGenerator class GeoFeedMixin: - def georss_coords(self, coords: Any) -> Any: ... - def add_georss_point(self, handler: Any, coords: Any, w3c_geo: bool = ...) -> None: ... - def add_georss_element(self, handler: Any, item: Any, w3c_geo: bool = ...) -> None: ... + def georss_coords(self, coords: Iterable[Sequence[float]]) -> str: ... + def add_georss_point(self, handler: SimplerXMLGenerator, coords: Sequence[float], w3c_geo: bool = ...) -> None: ... + def add_georss_element(self, handler: SimplerXMLGenerator, item: dict[str, Any], w3c_geo: bool = ...) -> None: ... class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin): - def rss_attributes(self) -> Any: ... - def add_item_elements(self, handler: Any, item: Any) -> None: ... - def add_root_elements(self, handler: Any) -> None: ... + def rss_attributes(self) -> dict[str, str]: ... -class GeoAtom1Feed(Atom1Feed, GeoFeedMixin): - def root_attributes(self) -> Any: ... - def add_item_elements(self, handler: Any, item: Any) -> None: ... - def add_root_elements(self, handler: Any) -> None: ... +class GeoAtom1Feed(Atom1Feed, GeoFeedMixin): ... class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin): - def rss_attributes(self) -> Any: ... - def add_item_elements(self, handler: Any, item: Any) -> None: ... - def add_root_elements(self, handler: Any) -> None: ... + def rss_attributes(self) -> dict[str, str]: ... -class Feed(BaseFeed): - feed_type: Any - def feed_extra_kwargs(self, obj: Any) -> Any: ... - def item_extra_kwargs(self, item: Any) -> Any: ... +class Feed(BaseFeed): ... diff --git a/django-stubs/contrib/gis/gdal/datasource.pyi b/django-stubs/contrib/gis/gdal/datasource.pyi index 105a8ee0d..c54faed30 100644 --- a/django-stubs/contrib/gis/gdal/datasource.pyi +++ b/django-stubs/contrib/gis/gdal/datasource.pyi @@ -1,16 +1,18 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.driver import Driver as Driver +from django.contrib.gis.gdal.layer import Layer as Layer class DataSource(GDALBase): destructor: Any - encoding: Any + encoding: str ptr: Any - driver: Any + driver: Driver def __init__(self, ds_input: Any, ds_driver: bool = ..., write: bool = ..., encoding: str = ...) -> None: ... - def __getitem__(self, index: Any) -> Any: ... + def __getitem__(self, index: str | int) -> Layer: ... def __len__(self) -> int: ... @property - def layer_count(self) -> Any: ... + def layer_count(self) -> int: ... @property - def name(self) -> Any: ... + def name(self) -> str: ... diff --git a/django-stubs/contrib/gis/gdal/driver.pyi b/django-stubs/contrib/gis/gdal/driver.pyi index 4fb87e647..c94ad3b59 100644 --- a/django-stubs/contrib/gis/gdal/driver.pyi +++ b/django-stubs/contrib/gis/gdal/driver.pyi @@ -8,6 +8,6 @@ class Driver(GDALBase): @classmethod def ensure_registered(cls) -> None: ... @classmethod - def driver_count(cls) -> Any: ... + def driver_count(cls) -> int: ... @property - def name(self) -> Any: ... + def name(self) -> str: ... diff --git a/django-stubs/contrib/gis/gdal/envelope.pyi b/django-stubs/contrib/gis/gdal/envelope.pyi index 44068f6ce..6bba207ab 100644 --- a/django-stubs/contrib/gis/gdal/envelope.pyi +++ b/django-stubs/contrib/gis/gdal/envelope.pyi @@ -6,20 +6,20 @@ class OGREnvelope(Structure): ... class Envelope: def __init__(self, *args: Any) -> None: ... def __eq__(self, other: object) -> bool: ... - def expand_to_include(self, *args: Any) -> Any: ... + def expand_to_include(self, *args: Any) -> None: ... @property - def min_x(self) -> Any: ... + def min_x(self) -> float: ... @property - def min_y(self) -> Any: ... + def min_y(self) -> float: ... @property - def max_x(self) -> Any: ... + def max_x(self) -> float: ... @property - def max_y(self) -> Any: ... + def max_y(self) -> float: ... @property - def ur(self) -> Any: ... + def ur(self) -> tuple[float, float]: ... @property - def ll(self) -> Any: ... + def ll(self) -> tuple[float, float]: ... @property - def tuple(self) -> Any: ... + def tuple(self) -> tuple[float, float, float, float]: ... @property - def wkt(self) -> Any: ... + def wkt(self) -> str: ... diff --git a/django-stubs/contrib/gis/gdal/feature.pyi b/django-stubs/contrib/gis/gdal/feature.pyi index 9d76734ed..3bff413fa 100644 --- a/django-stubs/contrib/gis/gdal/feature.pyi +++ b/django-stubs/contrib/gis/gdal/feature.pyi @@ -1,27 +1,30 @@ from typing import Any from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.field import Field as Field +from django.contrib.gis.gdal.geometries import OGRGeometry as OGRGeometry +from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType class Feature(GDALBase): destructor: Any ptr: Any def __init__(self, feat: Any, layer: Any) -> None: ... - def __getitem__(self, index: Any) -> Any: ... + def __getitem__(self, index: str | int) -> Field: ... def __len__(self) -> int: ... def __eq__(self, other: object) -> bool: ... @property - def encoding(self) -> Any: ... + def encoding(self) -> str: ... @property - def fid(self) -> Any: ... + def fid(self) -> int: ... @property - def layer_name(self) -> Any: ... + def layer_name(self) -> str: ... @property - def num_fields(self) -> Any: ... + def num_fields(self) -> int: ... @property - def fields(self) -> Any: ... + def fields(self) -> list[str]: ... @property - def geom(self) -> Any: ... + def geom(self) -> OGRGeometry: ... @property - def geom_type(self) -> Any: ... - def get(self, field: Any) -> Any: ... - def index(self, field_name: Any) -> Any: ... + def geom_type(self) -> OGRGeomType: ... + def get(self, field: str) -> Any: ... + def index(self, field_name: str) -> Any: ... diff --git a/django-stubs/contrib/gis/gdal/field.pyi b/django-stubs/contrib/gis/gdal/field.pyi index c573efdc1..0c5ac2400 100644 --- a/django-stubs/contrib/gis/gdal/field.pyi +++ b/django-stubs/contrib/gis/gdal/field.pyi @@ -5,24 +5,24 @@ from django.contrib.gis.gdal.base import GDALBase as GDALBase class Field(GDALBase): ptr: Any def __init__(self, feat: Any, index: Any) -> None: ... - def as_double(self) -> Any: ... - def as_int(self, is_64: bool = ...) -> Any: ... - def as_string(self) -> Any: ... - def as_datetime(self) -> Any: ... + def as_double(self) -> float | None: ... + def as_int(self, is_64: bool = ...) -> int | None: ... + def as_string(self) -> str | None: ... + def as_datetime(self) -> tuple[int, int, int, int, int, int, int] | None: ... @property - def is_set(self) -> Any: ... + def is_set(self) -> bool: ... @property - def name(self) -> Any: ... + def name(self) -> str: ... @property - def precision(self) -> Any: ... + def precision(self) -> int: ... @property - def type(self) -> Any: ... + def type(self) -> int: ... @property - def type_name(self) -> Any: ... + def type_name(self) -> bytes: ... @property def value(self) -> Any: ... @property - def width(self) -> Any: ... + def width(self) -> int: ... class OFTInteger(Field): @property diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index 409ea5e89..a4aa84253 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -1,135 +1,140 @@ -from typing import Any +from typing import Any, AnyStr from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.envelope import Envelope as Envelope +from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType +from django.contrib.gis.gdal.srs import CoordTransform as CoordTransform +from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference +from django.contrib.gis.geos import GEOSGeometry class OGRGeometry(GDALBase): destructor: Any ptr: Any - srs: Any - def __init__(self, geom_input: Any, srs: Any | None = ...) -> None: ... + srs: SpatialReference | None + def __init__(self, geom_input: Any, srs: SpatialReference | None = ...) -> None: ... @classmethod - def from_bbox(cls, bbox: Any) -> Any: ... + def from_bbox(cls, bbox: tuple[float, float, float, float]) -> OGRGeometry: ... @staticmethod - def from_json(geom_input: Any) -> Any: ... + def from_json(geom_input: AnyStr) -> OGRGeometry: ... @classmethod - def from_gml(cls, gml_string: Any) -> Any: ... - def __or__(self, other: Any) -> Any: ... - def __and__(self, other: Any) -> Any: ... - def __sub__(self, other: Any) -> Any: ... - def __xor__(self, other: Any) -> Any: ... + def from_gml(cls, gml_string: AnyStr) -> OGRGeometry: ... + def __or__(self, other: OGRGeometry) -> OGRGeometry: ... + def __and__(self, other: OGRGeometry) -> OGRGeometry: ... + def __sub__(self, other: OGRGeometry) -> OGRGeometry: ... + def __xor__(self, other: OGRGeometry) -> OGRGeometry: ... def __eq__(self, other: object) -> bool: ... @property - def dimension(self) -> Any: ... - coord_dim: Any + def dimension(self) -> int: ... + coord_dim: int @property - def geom_count(self) -> Any: ... + def geom_count(self) -> int: ... @property - def point_count(self) -> Any: ... + def point_count(self) -> int: ... @property - def num_points(self) -> Any: ... + def num_points(self) -> int: ... @property - def num_coords(self) -> Any: ... + def num_coords(self) -> int: ... @property - def geom_type(self) -> Any: ... + def geom_type(self) -> OGRGeomType: ... @property - def geom_name(self) -> Any: ... + def geom_name(self) -> str: ... @property - def area(self) -> Any: ... + def area(self) -> float: ... @property - def envelope(self) -> Any: ... + def envelope(self) -> Envelope: ... @property - def empty(self) -> Any: ... + def empty(self) -> bool: ... @property - def extent(self) -> Any: ... - srid: Any + def extent(self) -> tuple[float, float, float, float]: ... + srid: int | None @property - def geos(self) -> Any: ... + def geos(self) -> GEOSGeometry: ... @property - def gml(self) -> Any: ... + def gml(self) -> str: ... @property - def hex(self) -> Any: ... + def hex(self) -> bytes: ... @property - def json(self) -> Any: ... - geojson: Any + def json(self) -> str: ... + geojson: str @property - def kml(self) -> Any: ... + def kml(self) -> str: ... @property - def wkb_size(self) -> Any: ... + def wkb_size(self) -> int: ... @property - def wkb(self) -> Any: ... + def wkb(self) -> bytes: ... @property - def wkt(self) -> Any: ... + def wkt(self) -> str: ... @property - def ewkt(self) -> Any: ... + def ewkt(self) -> str: ... def clone(self) -> Any: ... def close_rings(self) -> None: ... - def transform(self, coord_trans: Any, clone: bool = ...) -> Any: ... - def intersects(self, other: Any) -> Any: ... - def equals(self, other: Any) -> Any: ... - def disjoint(self, other: Any) -> Any: ... - def touches(self, other: Any) -> Any: ... - def crosses(self, other: Any) -> Any: ... - def within(self, other: Any) -> Any: ... - def contains(self, other: Any) -> Any: ... - def overlaps(self, other: Any) -> Any: ... - @property - def boundary(self) -> Any: ... - @property - def convex_hull(self) -> Any: ... - def difference(self, other: Any) -> Any: ... - def intersection(self, other: Any) -> Any: ... - def sym_difference(self, other: Any) -> Any: ... - def union(self, other: Any) -> Any: ... + def transform(self, coord_trans: CoordTransform | SpatialReference | int | str, clone: bool = ...) -> Any: ... + def intersects(self, other: OGRGeometry) -> bool: ... + def equals(self, other: OGRGeometry) -> bool: ... + def disjoint(self, other: OGRGeometry) -> bool: ... + def touches(self, other: OGRGeometry) -> bool: ... + def crosses(self, other: OGRGeometry) -> bool: ... + def within(self, other: OGRGeometry) -> bool: ... + def contains(self, other: OGRGeometry) -> bool: ... + def overlaps(self, other: OGRGeometry) -> bool: ... + @property + def boundary(self) -> OGRGeometry: ... + @property + def convex_hull(self) -> OGRGeometry: ... + def difference(self, other: OGRGeometry) -> OGRGeometry: ... + def intersection(self, other: OGRGeometry) -> OGRGeometry: ... + def sym_difference(self, other: OGRGeometry) -> OGRGeometry: ... + def union(self, other: OGRGeometry) -> OGRGeometry: ... class Point(OGRGeometry): @property - def x(self) -> Any: ... + def x(self) -> float: ... @property - def y(self) -> Any: ... + def y(self) -> float: ... @property - def z(self) -> Any: ... + def z(self) -> float | None: ... @property - def tuple(self) -> Any: ... - coords: Any + def tuple(self) -> tuple[float, float] | tuple[float, float, float]: ... + coords: tuple[float, float] | tuple[float, float, float] class LineString(OGRGeometry): - def __getitem__(self, index: Any) -> Any: ... + def __getitem__(self, index: int) -> tuple[float, ...]: ... def __len__(self) -> int: ... @property - def tuple(self) -> Any: ... + def tuple(self) -> tuple[tuple[float, ...]]: ... coords: Any @property - def x(self) -> Any: ... + def x(self) -> list[float]: ... @property - def y(self) -> Any: ... + def y(self) -> list[float]: ... @property - def z(self) -> Any: ... + def z(self) -> list[float] | None: ... class LinearRing(LineString): ... class Polygon(OGRGeometry): def __len__(self) -> int: ... - def __getitem__(self, index: Any) -> Any: ... + def __getitem__(self, index: int) -> OGRGeometry: ... @property - def shell(self) -> Any: ... - exterior_ring: Any + def shell(self) -> OGRGeometry: ... + exterior_ring: OGRGeometry @property - def tuple(self) -> Any: ... - coords: Any + def tuple(self) -> tuple[tuple[tuple[float]]]: ... + coords: tuple[tuple[tuple[float]]] @property - def point_count(self) -> Any: ... + def point_count(self) -> int: ... @property - def centroid(self) -> Any: ... + def centroid(self) -> Point: ... class GeometryCollection(OGRGeometry): - def __getitem__(self, index: Any) -> Any: ... + def __getitem__(self, index: int) -> OGRGeometry: ... def __len__(self) -> int: ... - def add(self, geom: Any) -> None: ... + def add(self, geom: OGRGeometry | str) -> None: ... @property - def point_count(self) -> Any: ... + def point_count(self) -> int: ... @property - def tuple(self) -> Any: ... - coords: Any + def tuple(self) -> tuple[Any]: ... + coords: tuple[Any] class MultiPoint(GeometryCollection): ... class MultiLineString(GeometryCollection): ... diff --git a/django-stubs/contrib/gis/gdal/geomtype.pyi b/django-stubs/contrib/gis/gdal/geomtype.pyi index 177614065..d36533c92 100644 --- a/django-stubs/contrib/gis/gdal/geomtype.pyi +++ b/django-stubs/contrib/gis/gdal/geomtype.pyi @@ -2,11 +2,11 @@ from typing import Any class OGRGeomType: wkb25bit: int - num: Any + num: int def __init__(self, type_input: Any) -> None: ... def __eq__(self, other: object) -> bool: ... @property - def name(self) -> Any: ... + def name(self) -> str: ... @property - def django(self) -> Any: ... + def django(self) -> str: ... def to_multi(self) -> None: ... diff --git a/django-stubs/contrib/gis/gdal/layer.pyi b/django-stubs/contrib/gis/gdal/layer.pyi index b4d9c1f2f..6942e8c3f 100644 --- a/django-stubs/contrib/gis/gdal/layer.pyi +++ b/django-stubs/contrib/gis/gdal/layer.pyi @@ -1,33 +1,46 @@ from collections.abc import Iterator -from typing import Any +from typing import Any, AnyStr, Literal, overload from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.envelope import Envelope as Envelope +from django.contrib.gis.gdal.feature import Feature as Feature +from django.contrib.gis.gdal.field import Field as Field +from django.contrib.gis.gdal.geometries import OGRGeometry as OGRGeometry +from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType +from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference +from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry class Layer(GDALBase): ptr: Any def __init__(self, layer_ptr: Any, ds: Any) -> None: ... - def __getitem__(self, index: Any) -> Any: ... - def __iter__(self) -> Iterator[Any]: ... + @overload + def __getitem__(self, index: int) -> Feature: ... + @overload + def __getitem__(self, index: slice) -> list[Feature]: ... + def __iter__(self) -> Iterator[Feature]: ... def __len__(self) -> int: ... @property - def extent(self) -> Any: ... + def extent(self) -> Envelope: ... @property - def name(self) -> Any: ... + def name(self) -> str: ... @property - def num_fields(self) -> Any: ... + def num_fields(self) -> int: ... @property - def geom_type(self) -> Any: ... + def geom_type(self) -> OGRGeomType: ... @property - def srs(self) -> Any: ... + def srs(self) -> SpatialReference: ... @property - def fields(self) -> Any: ... + def fields(self) -> list[str]: ... @property - def field_types(self) -> Any: ... + def field_types(self) -> list[type[Field]]: ... @property - def field_widths(self) -> Any: ... + def field_widths(self) -> list[int]: ... @property - def field_precisions(self) -> Any: ... - spatial_filter: Any - def get_fields(self, field_name: Any) -> Any: ... - def get_geoms(self, geos: bool = ...) -> Any: ... - def test_capability(self, capability: Any) -> Any: ... + def field_precisions(self) -> list[int]: ... + spatial_filter: OGRGeometry | None + def get_fields(self, field_name: str) -> list[Any]: ... + @overload + def get_geoms(self, geos: Literal[True] = ...) -> OGRGeometry: ... + @overload + def get_geoms(self, geos: Literal[False]) -> GEOSGeometry: ... + def test_capability(self, capability: AnyStr) -> bool: ... diff --git a/django-stubs/contrib/gis/gdal/libgdal.pyi b/django-stubs/contrib/gis/gdal/libgdal.pyi index a271ede06..344436aa8 100644 --- a/django-stubs/contrib/gis/gdal/libgdal.pyi +++ b/django-stubs/contrib/gis/gdal/libgdal.pyi @@ -2,17 +2,17 @@ from logging import Logger from typing import Any logger: Logger -lib_path: Any -lib_names: Any +lib_path: str +lib_names: list[str] lgdal: Any lwingdal: Any def std_call(func: Any) -> Any: ... -def gdal_version() -> Any: ... -def gdal_full_version() -> Any: ... -def gdal_version_info() -> Any: ... +def gdal_version() -> bytes: ... +def gdal_full_version() -> bytes: ... +def gdal_version_info() -> tuple[int, int, int]: ... -GDAL_VERSION: Any +GDAL_VERSION: tuple[int, int, int] CPLErrorHandler: Any def err_handler(error_class: Any, error_number: Any, message: Any) -> None: ... diff --git a/django-stubs/contrib/gis/gdal/raster/band.pyi b/django-stubs/contrib/gis/gdal/raster/band.pyi index 42c9b4e2e..a4e2e5139 100644 --- a/django-stubs/contrib/gis/gdal/raster/band.pyi +++ b/django-stubs/contrib/gis/gdal/raster/band.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterator -from typing import Any +from typing import Any, Literal, overload from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase @@ -7,28 +7,36 @@ class GDALBand(GDALRasterBase): source: Any def __init__(self, source: Any, index: Any) -> None: ... @property - def description(self) -> Any: ... + def description(self) -> str: ... @property - def width(self) -> Any: ... + def width(self) -> int: ... @property - def height(self) -> Any: ... + def height(self) -> int: ... @property - def pixel_count(self) -> Any: ... - def statistics(self, refresh: bool = ..., approximate: bool = ...) -> Any: ... + def pixel_count(self) -> int: ... + def statistics( + self, refresh: bool = ..., approximate: bool = ... + ) -> tuple[float, float, float, float] | tuple[None, None, None, None]: ... @property - def min(self) -> Any: ... + def min(self) -> float | None: ... @property - def max(self) -> Any: ... + def max(self) -> float | None: ... @property - def mean(self) -> Any: ... + def mean(self) -> float | None: ... @property - def std(self) -> Any: ... + def std(self) -> float | None: ... @property - def nodata_value(self) -> Any: ... + def nodata_value(self) -> float | None: ... @nodata_value.setter - def nodata_value(self, value: Any) -> None: ... - def datatype(self, as_string: bool = ...) -> Any: ... - def color_interp(self, as_string: bool = ...) -> Any: ... + def nodata_value(self, value: float | None) -> None: ... + @overload + def datatype(self, as_string: Literal[False] = ...) -> int: ... + @overload + def datatype(self, as_string: Literal[True]) -> str: ... + @overload + def color_interp(self, as_string: Literal[False] = ...) -> int: ... + @overload + def color_interp(self, as_string: Literal[True] = ...) -> str: ... def data( self, data: Any | None = ..., @@ -41,6 +49,6 @@ class GDALBand(GDALRasterBase): class BandList(list): source: Any def __init__(self, source: Any) -> None: ... - def __iter__(self) -> Iterator[Any]: ... + def __iter__(self) -> Iterator[GDALBand]: ... def __len__(self) -> int: ... - def __getitem__(self, index: Any) -> Any: ... + def __getitem__(self, index: int) -> GDALBand: ... diff --git a/django-stubs/contrib/gis/gdal/raster/const.pyi b/django-stubs/contrib/gis/gdal/raster/const.pyi index a4fc208ac..e69b5dea8 100644 --- a/django-stubs/contrib/gis/gdal/raster/const.pyi +++ b/django-stubs/contrib/gis/gdal/raster/const.pyi @@ -1,10 +1,8 @@ -from typing import Any - -GDAL_PIXEL_TYPES: Any -GDAL_INTEGER_TYPES: Any -GDAL_TO_CTYPES: Any -GDAL_RESAMPLE_ALGORITHMS: Any -GDAL_COLOR_TYPES: Any +GDAL_PIXEL_TYPES: dict[int, str] +GDAL_INTEGER_TYPES: list[int] +GDAL_TO_CTYPES: type +GDAL_RESAMPLE_ALGORITHMS: dict[str, int] +GDAL_COLOR_TYPES: dict[int, str] VSI_FILESYSTEM_BASE_PATH: str VSI_TAKE_BUFFER_OWNERSHIP: bool VSI_DELETE_BUFFER_ON_READ: bool diff --git a/django-stubs/contrib/gis/gdal/raster/source.pyi b/django-stubs/contrib/gis/gdal/raster/source.pyi index a46e19b8f..57fecae6c 100644 --- a/django-stubs/contrib/gis/gdal/raster/source.pyi +++ b/django-stubs/contrib/gis/gdal/raster/source.pyi @@ -1,65 +1,68 @@ from typing import Any +from django.contrib.gis.gdal.driver import Driver as Driver +from django.contrib.gis.gdal.raster.band import BandList as BandList from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase +from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference class TransformPoint(list): - indices: Any - def __init__(self, raster: Any, prop: Any) -> None: ... + indices: dict[str, tuple[int, int]] + def __init__(self, raster: GDALRaster, prop: str) -> None: ... @property - def x(self) -> Any: ... + def x(self) -> float: ... @x.setter - def x(self, value: Any) -> None: ... + def x(self, value: float) -> None: ... @property - def y(self) -> Any: ... + def y(self) -> float: ... @y.setter - def y(self, value: Any) -> None: ... + def y(self, value: float) -> None: ... class GDALRaster(GDALRasterBase): destructor: Any def __init__(self, ds_input: Any, write: bool = ...) -> None: ... def __del__(self) -> None: ... @property - def vsi_buffer(self) -> Any: ... + def vsi_buffer(self) -> bytes | None: ... @property - def is_vsi_based(self) -> Any: ... + def is_vsi_based(self) -> bool: ... @property - def name(self) -> Any: ... + def name(self) -> str: ... @property - def driver(self) -> Any: ... + def driver(self) -> Driver: ... @property - def width(self) -> Any: ... + def width(self) -> int: ... @property - def height(self) -> Any: ... + def height(self) -> int: ... @property - def srs(self) -> Any: ... + def srs(self) -> SpatialReference | None: ... @srs.setter - def srs(self, value: Any) -> None: ... + def srs(self, value: SpatialReference | int | str) -> None: ... @property - def srid(self) -> Any: ... + def srid(self) -> int: ... @srid.setter - def srid(self, value: Any) -> None: ... + def srid(self, value: int) -> None: ... @property - def geotransform(self) -> Any: ... + def geotransform(self) -> list[float]: ... @geotransform.setter - def geotransform(self, values: Any) -> None: ... + def geotransform(self, values: list[float]) -> None: ... @property - def origin(self) -> Any: ... + def origin(self) -> TransformPoint: ... @property - def scale(self) -> Any: ... + def scale(self) -> TransformPoint: ... @property - def skew(self) -> Any: ... + def skew(self) -> TransformPoint: ... @property - def extent(self) -> Any: ... + def extent(self) -> tuple[float, float, float, float]: ... @property - def bands(self) -> Any: ... - def warp(self, ds_input: Any, resampling: str = ..., max_error: float = ...) -> Any: ... + def bands(self) -> BandList: ... + def warp(self, ds_input: Any, resampling: str = ..., max_error: float = ...) -> GDALRaster: ... def transform( self, - srs: Any, + srs: SpatialReference | int | str, driver: Any | None = ..., - name: Any | None = ..., + name: str | None = ..., resampling: str = ..., max_error: float = ..., - ) -> Any: ... + ) -> GDALRaster: ... @property - def info(self) -> Any: ... + def info(self) -> str: ... diff --git a/django-stubs/contrib/gis/gdal/srs.pyi b/django-stubs/contrib/gis/gdal/srs.pyi index cb298d363..f9043e6e3 100644 --- a/django-stubs/contrib/gis/gdal/srs.pyi +++ b/django-stubs/contrib/gis/gdal/srs.pyi @@ -1,6 +1,7 @@ from enum import IntEnum -from typing import Any +from typing import Any, AnyStr +from _typeshed import Self from django.contrib.gis.gdal.base import GDALBase as GDALBase class AxisOrder(IntEnum): @@ -9,59 +10,59 @@ class AxisOrder(IntEnum): class SpatialReference(GDALBase): destructor: Any - axis_order: Any + axis_order: AxisOrder ptr: Any - def __init__(self, srs_input: str = ..., srs_type: str = ..., axis_order: Any | None = ...) -> None: ... - def __getitem__(self, target: Any) -> Any: ... - def attr_value(self, target: Any, index: int = ...) -> Any: ... - def auth_name(self, target: Any) -> Any: ... - def auth_code(self, target: Any) -> Any: ... - def clone(self) -> Any: ... + def __init__(self, srs_input: str = ..., srs_type: str = ..., axis_order: AxisOrder | None = ...) -> None: ... + def __getitem__(self, target: str | tuple[str, int]) -> str: ... + def attr_value(self, target: AnyStr, index: int = ...) -> str: ... + def auth_name(self, target: AnyStr) -> str: ... + def auth_code(self, target: AnyStr) -> str: ... + def clone(self: Self) -> Self: ... def from_esri(self) -> None: ... def identify_epsg(self) -> None: ... def to_esri(self) -> None: ... def validate(self) -> None: ... @property - def name(self) -> Any: ... + def name(self) -> str | None: ... @property - def srid(self) -> Any: ... + def srid(self) -> int | None: ... @property - def linear_name(self) -> Any: ... + def linear_name(self) -> str: ... @property - def linear_units(self) -> Any: ... + def linear_units(self) -> float: ... @property - def angular_name(self) -> Any: ... + def angular_name(self) -> str: ... @property - def angular_units(self) -> Any: ... + def angular_units(self) -> float: ... @property - def units(self) -> Any: ... + def units(self) -> tuple[float | None, str | None]: ... @property - def ellipsoid(self) -> Any: ... + def ellipsoid(self) -> tuple[float, float, float]: ... @property - def semi_major(self) -> Any: ... + def semi_major(self) -> float: ... @property - def semi_minor(self) -> Any: ... + def semi_minor(self) -> float: ... @property - def inverse_flattening(self) -> Any: ... + def inverse_flattening(self) -> float: ... @property - def geographic(self) -> Any: ... + def geographic(self) -> bool: ... @property - def local(self) -> Any: ... + def local(self) -> bool: ... @property - def projected(self) -> Any: ... - def import_epsg(self, epsg: Any) -> None: ... - def import_proj(self, proj: Any) -> None: ... - def import_user_input(self, user_input: Any) -> None: ... - def import_wkt(self, wkt: Any) -> None: ... - def import_xml(self, xml: Any) -> None: ... + def projected(self) -> bool: ... + def import_epsg(self, epsg: int) -> None: ... + def import_proj(self, proj: AnyStr) -> None: ... + def import_user_input(self, user_input: AnyStr) -> None: ... + def import_wkt(self, wkt: AnyStr) -> None: ... + def import_xml(self, xml: AnyStr) -> None: ... @property - def wkt(self) -> Any: ... + def wkt(self) -> str: ... @property - def proj(self) -> Any: ... + def proj(self) -> str: ... @property - def proj4(self) -> Any: ... + def proj4(self) -> str: ... class CoordTransform(GDALBase): destructor: Any ptr: Any - def __init__(self, source: Any, target: Any) -> None: ... + def __init__(self, source: SpatialReference, target: SpatialReference) -> None: ... diff --git a/django-stubs/contrib/gis/geoip2/base.pyi b/django-stubs/contrib/gis/geoip2/base.pyi index 5dc5869d5..90b84ccb9 100644 --- a/django-stubs/contrib/gis/geoip2/base.pyi +++ b/django-stubs/contrib/gis/geoip2/base.pyi @@ -1,6 +1,10 @@ +from collections.abc import Sequence +from pathlib import Path from typing import Any -GEOIP_SETTINGS: Any +from django.contrib.gis.geos import Point + +GEOIP_SETTINGS: dict[str, Any] class GeoIP2Exception(Exception): ... @@ -10,20 +14,20 @@ class GeoIP2: MODE_MMAP: int MODE_FILE: int MODE_MEMORY: int - cache_options: Any + cache_options: frozenset def __init__( - self, path: Any | None = ..., cache: int = ..., country: Any | None = ..., city: Any | None = ... + self, path: Path | str | None = ..., cache: int = ..., country: Any | None = ..., city: Any | None = ... ) -> None: ... def __del__(self) -> None: ... - def city(self, query: Any) -> Any: ... - def country_code(self, query: Any) -> Any: ... - def country_name(self, query: Any) -> Any: ... - def country(self, query: Any) -> Any: ... - def coords(self, query: Any, ordering: Any = ...) -> Any: ... - def lon_lat(self, query: Any) -> Any: ... - def lat_lon(self, query: Any) -> Any: ... - def geos(self, query: Any) -> Any: ... + def city(self, query: str) -> dict[str, Any]: ... + def country_code(self, query: str) -> str: ... + def country_name(self, query: str) -> str: ... + def country(self, query: str) -> dict[str, Any]: ... + def coords(self, query: str, ordering: Sequence[str] = ...) -> tuple[float, float] | tuple[None, None]: ... + def lon_lat(self, query: str) -> tuple[float, float] | tuple[None, None]: ... + def lat_lon(self, query: str) -> tuple[float, float] | tuple[None, None]: ... + def geos(self, query: str) -> Point: ... @property - def info(self) -> Any: ... + def info(self) -> str: ... @classmethod - def open(cls, full_path: Any, cache: Any) -> Any: ... + def open(cls, full_path: Path | str | None, cache: int) -> Any: ... diff --git a/django-stubs/contrib/gis/geometry.pyi b/django-stubs/contrib/gis/geometry.pyi index 70a74206b..2bf08225c 100644 --- a/django-stubs/contrib/gis/geometry.pyi +++ b/django-stubs/contrib/gis/geometry.pyi @@ -1,5 +1,5 @@ -from typing import Any +from re import Pattern -hex_regex: Any -wkt_regex: Any -json_regex: Any +hex_regex: Pattern[str] +wkt_regex: Pattern[str] +json_regex: Pattern[str] diff --git a/django-stubs/contrib/gis/geos/base.pyi b/django-stubs/contrib/gis/geos/base.pyi index 63b092dc6..f4b282f17 100644 --- a/django-stubs/contrib/gis/geos/base.pyi +++ b/django-stubs/contrib/gis/geos/base.pyi @@ -1,6 +1,5 @@ -from typing import Any - +from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.ptr import CPointerBase as CPointerBase class GEOSBase(CPointerBase): - null_ptr_exception_class: Any + null_ptr_exception_class: type[GEOSException] diff --git a/django-stubs/contrib/gis/geos/collections.pyi b/django-stubs/contrib/gis/geos/collections.pyi index 2d9ed3002..585185a49 100644 --- a/django-stubs/contrib/gis/geos/collections.pyi +++ b/django-stubs/contrib/gis/geos/collections.pyi @@ -6,13 +6,11 @@ from django.contrib.gis.geos.geometry import LinearGeometryMixin as LinearGeomet class GeometryCollection(GEOSGeometry): def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def __iter__(self) -> Iterator[Any]: ... + def __iter__(self) -> Iterator[GEOSGeometry]: ... def __len__(self) -> int: ... @property - def kml(self) -> Any: ... - @property - def tuple(self) -> Any: ... - coords: Any + def tuple(self) -> tuple[Any]: ... + coords: tuple[Any] class MultiPoint(GeometryCollection): ... class MultiLineString(LinearGeometryMixin, GeometryCollection): ... diff --git a/django-stubs/contrib/gis/geos/coordseq.pyi b/django-stubs/contrib/gis/geos/coordseq.pyi index f5fa747f4..6c9672510 100644 --- a/django-stubs/contrib/gis/geos/coordseq.pyi +++ b/django-stubs/contrib/gis/geos/coordseq.pyi @@ -1,33 +1,34 @@ from collections.abc import Iterator from typing import Any +from _typeshed import Self from django.contrib.gis.geos.base import GEOSBase as GEOSBase class GEOSCoordSeq(GEOSBase): ptr_type: Any def __init__(self, ptr: Any, z: bool = ...) -> None: ... - def __iter__(self) -> Iterator[Any]: ... + def __iter__(self) -> Iterator[tuple[float, ...]]: ... def __len__(self) -> int: ... - def __getitem__(self, index: Any) -> Any: ... - def __setitem__(self, index: Any, value: Any) -> None: ... - def getOrdinate(self, dimension: Any, index: Any) -> Any: ... - def setOrdinate(self, dimension: Any, index: Any, value: Any) -> None: ... - def getX(self, index: Any) -> Any: ... - def setX(self, index: Any, value: Any) -> None: ... - def getY(self, index: Any) -> Any: ... - def setY(self, index: Any, value: Any) -> None: ... - def getZ(self, index: Any) -> Any: ... - def setZ(self, index: Any, value: Any) -> None: ... + def __getitem__(self, index: int) -> Any: ... + def __setitem__(self, index: int, value: Any) -> None: ... + def getOrdinate(self, dimension: int, index: int) -> float: ... + def setOrdinate(self, dimension: int, index: int, value: float) -> None: ... + def getX(self, index: int) -> float: ... + def setX(self, index: int, value: float) -> None: ... + def getY(self, index: int) -> float: ... + def setY(self, index: int, value: float) -> None: ... + def getZ(self, index: int) -> float: ... + def setZ(self, index: int, value: float) -> None: ... @property - def size(self) -> Any: ... + def size(self) -> int: ... @property - def dims(self) -> Any: ... + def dims(self) -> int: ... @property - def hasz(self) -> Any: ... - def clone(self) -> Any: ... + def hasz(self) -> bool: ... + def clone(self: Self) -> Self: ... @property - def kml(self) -> Any: ... + def kml(self) -> str: ... @property - def tuple(self) -> Any: ... + def tuple(self) -> tuple[Any]: ... @property - def is_counterclockwise(self) -> Any: ... + def is_counterclockwise(self) -> bool: ... diff --git a/django-stubs/contrib/gis/geos/factory.pyi b/django-stubs/contrib/gis/geos/factory.pyi index 81aeee71a..c4426dca4 100644 --- a/django-stubs/contrib/gis/geos/factory.pyi +++ b/django-stubs/contrib/gis/geos/factory.pyi @@ -1,4 +1,6 @@ -from typing import Any +from typing import IO, Any -def fromfile(file_h: Any) -> Any: ... -def fromstr(string: Any, **kwargs: Any) -> Any: ... +from django.contrib.gis.geos.geometry import GEOSGeometry + +def fromfile(file_h: str | IO) -> GEOSGeometry: ... +def fromstr(string: str, **kwargs: Any) -> GEOSGeometry: ... diff --git a/django-stubs/contrib/gis/geos/geometry.pyi b/django-stubs/contrib/gis/geos/geometry.pyi index bd64571cd..53abe1daa 100644 --- a/django-stubs/contrib/gis/geos/geometry.pyi +++ b/django-stubs/contrib/gis/geos/geometry.pyi @@ -1,11 +1,16 @@ -from typing import Any, TypeVar +from typing import Any from _typeshed import Self +from django.contrib.gis.gdal.geometries import OGRGeometry +from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference from django.contrib.gis.geometry import hex_regex as hex_regex # noqa: F401 from django.contrib.gis.geometry import json_regex as json_regex from django.contrib.gis.geometry import wkt_regex as wkt_regex from django.contrib.gis.geos.base import GEOSBase as GEOSBase +from django.contrib.gis.geos.coordseq import GEOSCoordSeq as GEOSCoordSeq from django.contrib.gis.geos.mutable_list import ListMixin as ListMixin +from django.contrib.gis.geos.point import Point +from django.contrib.gis.geos.prepared import PreparedGeometry as PreparedGeometry class GEOSGeometryBase(GEOSBase): ptr_type: Any @@ -15,125 +20,129 @@ class GEOSGeometryBase(GEOSBase): def __copy__(self: Self) -> Self: ... def __deepcopy__(self: Self, memodict: Any) -> Self: ... @staticmethod - def from_ewkt(ewkt: Any) -> Any: ... + def from_ewkt(ewkt: str) -> GEOSGeometry: ... @classmethod - def from_gml(cls, gml_string: Any) -> Any: ... + def from_gml(cls, gml_string: str) -> GEOSGeometry: ... def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... - def __or__(self, other: Any) -> Any: ... - def __and__(self, other: Any) -> Any: ... - def __sub__(self, other: Any) -> Any: ... - def __xor__(self, other: Any) -> Any: ... + def __or__(self, other: GEOSGeometry) -> GEOSGeometry: ... + def __and__(self, other: GEOSGeometry) -> GEOSGeometry: ... + def __sub__(self, other: GEOSGeometry) -> GEOSGeometry: ... + def __xor__(self, other: GEOSGeometry) -> GEOSGeometry: ... @property - def coord_seq(self) -> Any: ... + def coord_seq(self) -> GEOSCoordSeq | None: ... @property - def geom_type(self) -> Any: ... + def geom_type(self) -> str: ... @property - def geom_typeid(self) -> Any: ... + def geom_typeid(self) -> int: ... @property - def num_geom(self) -> Any: ... + def num_geom(self) -> int: ... @property - def num_coords(self) -> Any: ... + def num_coords(self) -> int: ... @property - def num_points(self) -> Any: ... + def num_points(self) -> int: ... @property - def dims(self) -> Any: ... + def dims(self) -> int: ... def normalize(self) -> None: ... @property - def empty(self) -> Any: ... + def empty(self) -> bool: ... @property - def hasz(self) -> Any: ... + def hasz(self) -> bool: ... @property - def ring(self) -> Any: ... + def ring(self) -> bool: ... @property - def simple(self) -> Any: ... + def simple(self) -> bool: ... @property - def valid(self) -> Any: ... + def valid(self) -> bool: ... @property - def valid_reason(self) -> Any: ... - def contains(self, other: Any) -> Any: ... - def covers(self, other: Any) -> Any: ... - def crosses(self, other: Any) -> Any: ... - def disjoint(self, other: Any) -> Any: ... - def equals(self, other: Any) -> Any: ... - def equals_exact(self, other: Any, tolerance: float = ...) -> Any: ... - def intersects(self, other: Any) -> Any: ... - def overlaps(self, other: Any) -> Any: ... - def relate_pattern(self, other: Any, pattern: Any) -> Any: ... - def touches(self, other: Any) -> Any: ... - def within(self, other: Any) -> Any: ... + def valid_reason(self) -> str: ... + def contains(self, other: GEOSGeometry) -> bool: ... + def covers(self, other: GEOSGeometry) -> bool: ... + def crosses(self, other: GEOSGeometry) -> bool: ... + def disjoint(self, other: GEOSGeometry) -> bool: ... + def equals(self, other: GEOSGeometry) -> bool: ... + def equals_exact(self, other: GEOSGeometry, tolerance: float = ...) -> bool: ... + def intersects(self, other: GEOSGeometry) -> bool: ... + def overlaps(self, other: GEOSGeometry) -> bool: ... + def relate_pattern(self, other: GEOSGeometry, pattern: str) -> bool: ... + def touches(self, other: GEOSGeometry) -> bool: ... + def within(self, other: GEOSGeometry) -> bool: ... @property - def srid(self) -> Any: ... + def srid(self) -> int | None: ... @srid.setter - def srid(self, srid: Any) -> None: ... + def srid(self, srid: int | None) -> None: ... @property - def ewkt(self) -> Any: ... + def ewkt(self) -> str: ... @property - def wkt(self) -> Any: ... + def wkt(self) -> str: ... @property - def hex(self) -> Any: ... + def hex(self) -> bytes: ... @property - def hexewkb(self) -> Any: ... + def hexewkb(self) -> bytes: ... @property - def json(self) -> Any: ... - geojson: Any + def json(self) -> str: ... + geojson: str @property - def wkb(self) -> Any: ... + def wkb(self) -> bytes: ... @property - def ewkb(self) -> Any: ... + def ewkb(self) -> bytes: ... @property - def kml(self) -> Any: ... + def kml(self) -> str: ... @property - def prepared(self) -> Any: ... + def prepared(self) -> PreparedGeometry: ... @property - def ogr(self) -> Any: ... + def ogr(self) -> OGRGeometry: ... @property - def srs(self) -> Any: ... + def srs(self) -> SpatialReference | None: ... @property - def crs(self) -> Any: ... + def crs(self) -> SpatialReference | None: ... ptr: Any - def transform(self, ct: Any, clone: bool = ...) -> Any: ... + def transform(self, ct: int | CoordTransform, clone: bool = ...) -> GEOSGeometry: ... @property - def boundary(self) -> Any: ... - def buffer(self, width: Any, quadsegs: int = ...) -> Any: ... + def boundary(self) -> GEOSGeometry: ... + def buffer(self, width: float, quadsegs: int = ...) -> GEOSGeometry: ... def buffer_with_style( - self, width: Any, quadsegs: int = ..., end_cap_style: int = ..., join_style: int = ..., mitre_limit: float = ... - ) -> Any: ... + self, + width: float, + quadsegs: int = ..., + end_cap_style: int = ..., + join_style: int = ..., + mitre_limit: float = ..., + ) -> GEOSGeometry: ... @property - def centroid(self) -> Any: ... + def centroid(self) -> Point: ... @property - def convex_hull(self) -> Any: ... - def difference(self, other: Any) -> Any: ... + def convex_hull(self) -> GEOSGeometry: ... + def difference(self, other: GEOSGeometry) -> GEOSGeometry: ... @property - def envelope(self) -> Any: ... - def intersection(self, other: Any) -> Any: ... + def envelope(self) -> GEOSGeometry: ... + def intersection(self, other: GEOSGeometry) -> GEOSGeometry: ... @property - def point_on_surface(self) -> Any: ... - def relate(self, other: Any) -> Any: ... - def simplify(self, tolerance: float = ..., preserve_topology: bool = ...) -> Any: ... - def sym_difference(self, other: Any) -> Any: ... + def point_on_surface(self) -> Point: ... + def relate(self, other: GEOSGeometry) -> str: ... + def simplify(self, tolerance: float = ..., preserve_topology: bool = ...) -> GEOSGeometry: ... + def sym_difference(self, other: GEOSGeometry) -> GEOSGeometry: ... @property - def unary_union(self) -> Any: ... - def union(self, other: Any) -> Any: ... + def unary_union(self) -> GEOSGeometry: ... + def union(self, other: GEOSGeometry) -> GEOSGeometry: ... @property - def area(self) -> Any: ... - def distance(self, other: Any) -> Any: ... + def area(self) -> float: ... + def distance(self, other: GEOSGeometry) -> float: ... @property - def extent(self) -> Any: ... + def extent(self) -> tuple[float, float, float, float]: ... @property - def length(self) -> Any: ... - def clone(self) -> Any: ... + def length(self) -> float: ... + def clone(self: Self) -> Self: ... class LinearGeometryMixin: - def interpolate(self, distance: Any) -> Any: ... - def interpolate_normalized(self, distance: Any) -> Any: ... - def project(self, point: Any) -> Any: ... - def project_normalized(self, point: Any) -> Any: ... + def interpolate(self, distance: float) -> Point: ... + def interpolate_normalized(self, distance: float) -> Point: ... + def project(self, point: Point) -> float: ... + def project_normalized(self, point: Point) -> float: ... @property - def merged(self) -> Any: ... + def merged(self) -> GEOSGeometry: ... @property - def closed(self) -> Any: ... + def closed(self) -> bool: ... class GEOSGeometry(GEOSGeometryBase, ListMixin): - srid: Any - def __init__(self, geo_input: Any, srid: Any | None = ...) -> None: ... + def __init__(self, geo_input: Any, srid: int | None = ...) -> None: ... diff --git a/django-stubs/contrib/gis/geos/io.pyi b/django-stubs/contrib/gis/geos/io.pyi index c1fed95a3..c061120f2 100644 --- a/django-stubs/contrib/gis/geos/io.pyi +++ b/django-stubs/contrib/gis/geos/io.pyi @@ -1,11 +1,12 @@ from typing import Any +from django.contrib.gis.geos.geometry import GEOSGeometry from django.contrib.gis.geos.prototypes.io import WKBWriter as WKBWriter # noqa: F401 from django.contrib.gis.geos.prototypes.io import WKTWriter as WKTWriter from django.contrib.gis.geos.prototypes.io import _WKBReader, _WKTReader class WKBReader(_WKBReader): - def read(self, wkb: Any) -> Any: ... + def read(self, wkb: bytes | str) -> GEOSGeometry: ... class WKTReader(_WKTReader): - def read(self, wkt: Any) -> Any: ... + def read(self, wkt: bytes | str) -> GEOSGeometry: ... diff --git a/django-stubs/contrib/gis/geos/libgeos.pyi b/django-stubs/contrib/gis/geos/libgeos.pyi index 1b4c9725d..406f52708 100644 --- a/django-stubs/contrib/gis/geos/libgeos.pyi +++ b/django-stubs/contrib/gis/geos/libgeos.pyi @@ -37,5 +37,5 @@ class GEOSFuncFactory: @property def func(self) -> Any: ... -def geos_version() -> Any: ... -def geos_version_tuple() -> Any: ... +def geos_version() -> bytes: ... +def geos_version_tuple() -> tuple[int, ...]: ... diff --git a/django-stubs/contrib/gis/geos/linestring.pyi b/django-stubs/contrib/gis/geos/linestring.pyi index c022e31fe..cd59f4dd0 100644 --- a/django-stubs/contrib/gis/geos/linestring.pyi +++ b/django-stubs/contrib/gis/geos/linestring.pyi @@ -7,11 +7,11 @@ from django.contrib.gis.geos.geometry import LinearGeometryMixin as LinearGeomet class LineString(LinearGeometryMixin, GEOSGeometry): has_cs: bool def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def __iter__(self) -> Iterator[Any]: ... + def __iter__(self) -> Iterator[tuple[float, ...]]: ... def __len__(self) -> int: ... @property - def tuple(self) -> Any: ... - coords: Any + def tuple(self) -> tuple[tuple[float, ...]]: ... + coords: tuple[tuple[float, ...]] @property def array(self) -> Any: ... @property @@ -23,4 +23,4 @@ class LineString(LinearGeometryMixin, GEOSGeometry): class LinearRing(LineString): @property - def is_counterclockwise(self) -> Any: ... + def is_counterclockwise(self) -> bool: ... diff --git a/django-stubs/contrib/gis/geos/mutable_list.pyi b/django-stubs/contrib/gis/geos/mutable_list.pyi index e17cff6ed..7d7d58fbe 100644 --- a/django-stubs/contrib/gis/geos/mutable_list.pyi +++ b/django-stubs/contrib/gis/geos/mutable_list.pyi @@ -4,22 +4,22 @@ from _typeshed import Self class ListMixin: def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def __getitem__(self, index: Any) -> Any: ... - def __delitem__(self, index: Any) -> None: ... - def __setitem__(self, index: Any, val: Any) -> None: ... - def __add__(self, other: Any) -> Any: ... + def __getitem__(self, index: int | slice) -> Any: ... + def __delitem__(self, index: int | slice) -> None: ... + def __setitem__(self, index: int | slice, val: Any) -> None: ... + def __add__(self: Self, other: Any) -> Self: ... def __radd__(self, other: Any) -> Any: ... def __iadd__(self: Self, other: Any) -> Self: ... - def __mul__(self, n: Any) -> Any: ... - def __rmul__(self, n: Any) -> Any: ... - def __imul__(self: Self, n: Any) -> Self: ... + def __mul__(self: Self, n: int) -> Self: ... + def __rmul__(self: Self, n: int) -> Self: ... + def __imul__(self: Self, n: int) -> Self: ... def __eq__(self, other: object) -> bool: ... def __lt__(self, other: Any) -> bool: ... - def count(self, val: Any) -> Any: ... - def index(self, val: Any) -> Any: ... + def count(self, val: Any) -> int: ... + def index(self, val: Any) -> int: ... def append(self, val: Any) -> None: ... def extend(self, vals: Any) -> None: ... - def insert(self, index: Any, val: Any) -> None: ... + def insert(self, index: int, val: Any) -> None: ... def pop(self, index: int = ...) -> Any: ... def remove(self, val: Any) -> None: ... def reverse(self) -> None: ... diff --git a/django-stubs/contrib/gis/geos/point.pyi b/django-stubs/contrib/gis/geos/point.pyi index ad66e45ca..668bf00e7 100644 --- a/django-stubs/contrib/gis/geos/point.pyi +++ b/django-stubs/contrib/gis/geos/point.pyi @@ -8,22 +8,22 @@ class Point(GEOSGeometry): def __init__( self, x: Any | None = ..., y: Any | None = ..., z: Any | None = ..., srid: Any | None = ... ) -> None: ... - def __iter__(self) -> Iterator[Any]: ... + def __iter__(self) -> Iterator[float]: ... def __len__(self) -> int: ... @property - def x(self) -> Any: ... + def x(self) -> float: ... @x.setter - def x(self, value: Any) -> None: ... + def x(self, value: float) -> None: ... @property - def y(self) -> Any: ... + def y(self) -> float: ... @y.setter - def y(self, value: Any) -> None: ... + def y(self, value: float) -> None: ... @property - def z(self) -> Any: ... + def z(self) -> float | None: ... @z.setter - def z(self, value: Any) -> None: ... + def z(self, value: float) -> None: ... @property - def tuple(self) -> Any: ... + def tuple(self) -> tuple[float, ...]: ... @tuple.setter def tuple(self, tup: Any) -> None: ... - coords: Any + coords: tuple[float, ...] diff --git a/django-stubs/contrib/gis/geos/polygon.pyi b/django-stubs/contrib/gis/geos/polygon.pyi index cff17a912..f24f4cace 100644 --- a/django-stubs/contrib/gis/geos/polygon.pyi +++ b/django-stubs/contrib/gis/geos/polygon.pyi @@ -2,19 +2,18 @@ from collections.abc import Iterator from typing import Any from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry +from django.contrib.gis.geos.linestring import LinearRing as LinearRing class Polygon(GEOSGeometry): def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def __iter__(self) -> Iterator[Any]: ... + def __iter__(self) -> Iterator[LinearRing]: ... def __len__(self) -> int: ... @classmethod - def from_bbox(cls, bbox: Any) -> Any: ... + def from_bbox(cls, bbox: tuple[float, float, float, float]) -> Polygon: ... @property - def num_interior_rings(self) -> Any: ... - exterior_ring: Any - shell: Any + def num_interior_rings(self) -> int: ... + exterior_ring: LinearRing + shell: LinearRing @property - def tuple(self) -> Any: ... - coords: Any - @property - def kml(self) -> Any: ... + def tuple(self) -> tuple[tuple[tuple[float, ...]]]: ... + coords: tuple[tuple[tuple[float, ...]]] diff --git a/django-stubs/contrib/gis/geos/prepared.pyi b/django-stubs/contrib/gis/geos/prepared.pyi index a0aa425ce..b6f6e4247 100644 --- a/django-stubs/contrib/gis/geos/prepared.pyi +++ b/django-stubs/contrib/gis/geos/prepared.pyi @@ -1,18 +1,19 @@ from typing import Any from .base import GEOSBase as GEOSBase +from .geometry import GEOSGeometry as GEOSGeometry class PreparedGeometry(GEOSBase): ptr_type: Any destructor: Any ptr: Any def __init__(self, geom: Any) -> None: ... - def contains(self, other: Any) -> Any: ... - def contains_properly(self, other: Any) -> Any: ... - def covers(self, other: Any) -> Any: ... - def intersects(self, other: Any) -> Any: ... - def crosses(self, other: Any) -> Any: ... - def disjoint(self, other: Any) -> Any: ... - def overlaps(self, other: Any) -> Any: ... - def touches(self, other: Any) -> Any: ... - def within(self, other: Any) -> Any: ... + def contains(self, other: GEOSGeometry) -> bool: ... + def contains_properly(self, other: GEOSGeometry) -> bool: ... + def covers(self, other: GEOSGeometry) -> bool: ... + def intersects(self, other: GEOSGeometry) -> bool: ... + def crosses(self, other: GEOSGeometry) -> bool: ... + def disjoint(self, other: GEOSGeometry) -> bool: ... + def overlaps(self, other: GEOSGeometry) -> bool: ... + def touches(self, other: GEOSGeometry) -> bool: ... + def within(self, other: GEOSGeometry) -> bool: ... diff --git a/django-stubs/contrib/gis/measure.pyi b/django-stubs/contrib/gis/measure.pyi index cd72527b7..16bacd9e9 100644 --- a/django-stubs/contrib/gis/measure.pyi +++ b/django-stubs/contrib/gis/measure.pyi @@ -1,45 +1,40 @@ +from decimal import Decimal from typing import Any from _typeshed import Self from typing_extensions import TypeAlias +_NUMERIC_TYPES: TypeAlias = int | float | Decimal + class MeasureBase: - STANDARD_UNIT: Any - ALIAS: Any - UNITS: Any - LALIAS: Any - def __init__(self, default_unit: Any | None = ..., **kwargs: Any) -> None: ... + STANDARD_UNIT: str | None + UNITS: dict[str, float] + ALIAS: dict[str, str] + LALIAS: dict[str, str] + def __init__(self, default_unit: str | None = ..., **kwargs: Any) -> None: ... standard: Any - def __getattr__(self, name: Any) -> Any: ... + def __getattr__(self, name: str) -> float: ... def __eq__(self, other: object) -> bool: ... - def __lt__(self, other: Any) -> bool: ... - def __add__(self, other: Any) -> Any: ... - def __iadd__(self: Self, other: Any) -> Self: ... - def __sub__(self, other: Any) -> Any: ... - def __isub__(self: Self, other: Any) -> Self: ... - def __mul__(self, other: Any) -> Any: ... - def __imul__(self: Self, other: Any) -> Self: ... - def __rmul__(self, other: Any) -> Any: ... - def __truediv__(self, other: Any) -> Any: ... - def __itruediv__(self: Self, other: Any) -> Self: ... + def __lt__(self: Self, other: Self) -> bool: ... + def __add__(self: Self, other: Self) -> Self: ... + def __iadd__(self: Self, other: Self) -> Self: ... + def __sub__(self: Self, other: Self) -> Self: ... + def __isub__(self: Self, other: Self) -> Self: ... + def __mul__(self, other: _NUMERIC_TYPES) -> Any: ... + def __imul__(self: Self, other: _NUMERIC_TYPES) -> Self: ... + def __rmul__(self: Self, other: _NUMERIC_TYPES) -> Self: ... + def __truediv__(self: Self, other: _NUMERIC_TYPES) -> Self: ... + def __itruediv__(self: Self, other: _NUMERIC_TYPES) -> Self: ... def __bool__(self) -> bool: ... - def default_units(self, kwargs: Any) -> Any: ... + def default_units(self, kwargs: dict[str, Any]) -> tuple[float, str]: ... @classmethod - def unit_attname(cls, unit_str: Any) -> Any: ... + def unit_attname(cls, unit_str: str) -> str: ... class Distance(MeasureBase): STANDARD_UNIT: str - UNITS: Any - ALIAS: Any - LALIAS: Any - def __mul__(self, other: Any) -> Any: ... class Area(MeasureBase): - STANDARD_UNIT: Any - UNITS: Any - ALIAS: Any - LALIAS: Any - def __truediv__(self, other: Any) -> Any: ... + STANDARD_UNIT: str D: TypeAlias = Distance diff --git a/django-stubs/contrib/gis/shortcuts.pyi b/django-stubs/contrib/gis/shortcuts.pyi index df669774c..cb2f0443b 100644 --- a/django-stubs/contrib/gis/shortcuts.pyi +++ b/django-stubs/contrib/gis/shortcuts.pyi @@ -1,5 +1,7 @@ from typing import Any -def compress_kml(kml: Any) -> Any: ... -def render_to_kml(*args: Any, **kwargs: Any) -> Any: ... -def render_to_kmz(*args: Any, **kwargs: Any) -> Any: ... +from django.http.response import HttpResponse + +def compress_kml(kml: str) -> bytes: ... +def render_to_kml(*args: Any, **kwargs: Any) -> HttpResponse: ... +def render_to_kmz(*args: Any, **kwargs: Any) -> HttpResponse: ... diff --git a/django-stubs/contrib/gis/utils/layermapping.pyi b/django-stubs/contrib/gis/utils/layermapping.pyi index 032883824..eb20798b3 100644 --- a/django-stubs/contrib/gis/utils/layermapping.pyi +++ b/django-stubs/contrib/gis/utils/layermapping.pyi @@ -1,4 +1,12 @@ -from typing import Any +from collections.abc import Mapping +from pathlib import Path +from typing import Any, TextIO + +from django.contrib.gis.gdal import DataSource, OGRGeomType +from django.contrib.gis.gdal.field import Field as OGRField +from django.contrib.gis.gdal.layer import Layer +from django.db.backends.base.operations import BaseDatabaseOperations +from django.db.models import Field, Model class LayerMapError(Exception): ... class InvalidString(LayerMapError): ... @@ -7,38 +15,38 @@ class InvalidInteger(LayerMapError): ... class MissingForeignKey(LayerMapError): ... class LayerMapping: - MULTI_TYPES: Any - FIELD_TYPES: Any - ds: Any - layer: Any - using: Any - spatial_backend: Any - mapping: Any - model: Any + MULTI_TYPES: dict[int, OGRGeomType] + FIELD_TYPES: dict[Field, OGRField | tuple[OGRField, ...]] + ds: DataSource + layer: Layer + using: str + spatial_backend: BaseDatabaseOperations + mapping: Mapping[str, str] + model: type[Model] geo_field: Any source_srs: Any transform: Any - encoding: Any - unique: Any + encoding: str | None + unique: list | tuple | str | None transaction_mode: Any transaction_decorator: Any def __init__( self, - model: Any, - data: Any, - mapping: Any, + model: type[Model], + data: str | Path | DataSource, + mapping: Mapping[str, str], layer: int = ..., source_srs: Any | None = ..., encoding: str = ..., transaction_mode: str = ..., transform: bool = ..., - unique: Any | None = ..., - using: Any | None = ..., + unique: list | tuple | str | None = ..., + using: str | None = ..., ) -> None: ... def check_fid_range(self, fid_range: Any) -> Any: ... geom_field: str - fields: Any - coord_dim: Any + fields: dict[str, Field] + coord_dim: int def check_layer(self) -> Any: ... def check_srs(self, source_srs: Any) -> Any: ... def check_unique(self, unique: Any) -> None: ... @@ -57,6 +65,6 @@ class LayerMapping: step: bool = ..., progress: bool = ..., silent: bool = ..., - stream: Any = ..., + stream: TextIO = ..., strict: bool = ..., ) -> Any: ... diff --git a/django-stubs/contrib/gis/utils/ogrinfo.pyi b/django-stubs/contrib/gis/utils/ogrinfo.pyi index 9190fb11c..18fd4f02f 100644 --- a/django-stubs/contrib/gis/utils/ogrinfo.pyi +++ b/django-stubs/contrib/gis/utils/ogrinfo.pyi @@ -1,3 +1,5 @@ from typing import Any -def ogrinfo(data_source: Any, num_features: int = ...) -> None: ... +from django.contrib.gis.gdal import DataSource + +def ogrinfo(data_source: str | DataSource, num_features: int = ...) -> None: ... diff --git a/django-stubs/contrib/gis/utils/ogrinspect.pyi b/django-stubs/contrib/gis/utils/ogrinspect.pyi index 355cd762e..cc6874c5d 100644 --- a/django-stubs/contrib/gis/utils/ogrinspect.pyi +++ b/django-stubs/contrib/gis/utils/ogrinspect.pyi @@ -1,4 +1,8 @@ from typing import Any -def mapping(data_source: Any, geom_name: str = ..., layer_key: int = ..., multi_geom: bool = ...) -> Any: ... -def ogrinspect(*args: Any, **kwargs: Any) -> Any: ... +from django.contrib.gis.gdal import DataSource + +def mapping( + data_source: str | DataSource, geom_name: str = ..., layer_key: int | str = ..., multi_geom: bool = ... +) -> dict[str, str]: ... +def ogrinspect(data_source: str | DataSource, model_name: str, *args: Any, **kwargs: Any) -> str: ... From d0d9209bd6f280eaa0c83a16ec0a267a04b3e5ff Mon Sep 17 00:00:00 2001 From: Taku Fukada Date: Sun, 25 Dec 2022 21:36:43 +0900 Subject: [PATCH 3/6] Fixes for mypy errors --- django-stubs/contrib/gis/gdal/geometries.pyi | 13 ++++++++----- django-stubs/contrib/gis/gdal/layer.pyi | 3 ++- django-stubs/contrib/gis/gdal/raster/band.pyi | 11 ++++------- django-stubs/contrib/gis/gdal/raster/source.pyi | 3 ++- django-stubs/contrib/gis/geoip2/base.pyi | 2 +- django-stubs/contrib/gis/geos/collections.pyi | 5 +++-- django-stubs/contrib/gis/geos/coordseq.pyi | 2 +- django-stubs/contrib/gis/geos/factory.pyi | 4 ++-- django-stubs/contrib/gis/geos/linestring.pyi | 3 ++- django-stubs/contrib/gis/geos/point.pyi | 7 +++---- django-stubs/contrib/gis/geos/polygon.pyi | 3 ++- django-stubs/contrib/gis/measure.pyi | 2 +- django-stubs/contrib/gis/utils/layermapping.pyi | 4 ++-- 13 files changed, 33 insertions(+), 29 deletions(-) diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index a4aa84253..c8618c521 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -94,8 +94,9 @@ class Point(OGRGeometry): @property def z(self) -> float | None: ... @property + def coords(self) -> tuple[float, float] | tuple[float, float, float]: ... + @property def tuple(self) -> tuple[float, float] | tuple[float, float, float]: ... - coords: tuple[float, float] | tuple[float, float, float] class LineString(OGRGeometry): def __getitem__(self, index: int) -> tuple[float, ...]: ... @@ -119,8 +120,9 @@ class Polygon(OGRGeometry): def shell(self) -> OGRGeometry: ... exterior_ring: OGRGeometry @property - def tuple(self) -> tuple[tuple[tuple[float]]]: ... - coords: tuple[tuple[tuple[float]]] + def coords(self) -> tuple[tuple[tuple[float, ...]]]: ... + @property + def tuple(self) -> tuple[tuple[tuple[float, ...]]]: ... @property def point_count(self) -> int: ... @property @@ -133,8 +135,9 @@ class GeometryCollection(OGRGeometry): @property def point_count(self) -> int: ... @property - def tuple(self) -> tuple[Any]: ... - coords: tuple[Any] + def coords(self) -> tuple[Any, ...]: ... + @property + def tuple(self) -> tuple[Any, ...]: ... class MultiPoint(GeometryCollection): ... class MultiLineString(GeometryCollection): ... diff --git a/django-stubs/contrib/gis/gdal/layer.pyi b/django-stubs/contrib/gis/gdal/layer.pyi index 6942e8c3f..7d2e7d929 100644 --- a/django-stubs/contrib/gis/gdal/layer.pyi +++ b/django-stubs/contrib/gis/gdal/layer.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterator -from typing import Any, AnyStr, Literal, overload +from typing import Any, AnyStr, overload from django.contrib.gis.gdal.base import GDALBase as GDALBase from django.contrib.gis.gdal.envelope import Envelope as Envelope @@ -9,6 +9,7 @@ from django.contrib.gis.gdal.geometries import OGRGeometry as OGRGeometry from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry +from typing_extensions import Literal class Layer(GDALBase): ptr: Any diff --git a/django-stubs/contrib/gis/gdal/raster/band.pyi b/django-stubs/contrib/gis/gdal/raster/band.pyi index a4e2e5139..e5469b4ee 100644 --- a/django-stubs/contrib/gis/gdal/raster/band.pyi +++ b/django-stubs/contrib/gis/gdal/raster/band.pyi @@ -1,7 +1,7 @@ -from collections.abc import Iterator -from typing import Any, Literal, overload +from typing import Any, overload from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase +from typing_extensions import Literal class GDALBand(GDALRasterBase): source: Any @@ -36,7 +36,7 @@ class GDALBand(GDALRasterBase): @overload def color_interp(self, as_string: Literal[False] = ...) -> int: ... @overload - def color_interp(self, as_string: Literal[True] = ...) -> str: ... + def color_interp(self, as_string: Literal[True]) -> str: ... def data( self, data: Any | None = ..., @@ -46,9 +46,6 @@ class GDALBand(GDALRasterBase): as_memoryview: bool = ..., ) -> Any: ... -class BandList(list): +class BandList(list[GDALBand]): source: Any def __init__(self, source: Any) -> None: ... - def __iter__(self) -> Iterator[GDALBand]: ... - def __len__(self) -> int: ... - def __getitem__(self, index: int) -> GDALBand: ... diff --git a/django-stubs/contrib/gis/gdal/raster/source.pyi b/django-stubs/contrib/gis/gdal/raster/source.pyi index 57fecae6c..a66e4676c 100644 --- a/django-stubs/contrib/gis/gdal/raster/source.pyi +++ b/django-stubs/contrib/gis/gdal/raster/source.pyi @@ -1,3 +1,4 @@ +from collections.abc import Sequence from typing import Any from django.contrib.gis.gdal.driver import Driver as Driver @@ -5,7 +6,7 @@ from django.contrib.gis.gdal.raster.band import BandList as BandList from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference -class TransformPoint(list): +class TransformPoint(list[Sequence[float]]): indices: dict[str, tuple[int, int]] def __init__(self, raster: GDALRaster, prop: str) -> None: ... @property diff --git a/django-stubs/contrib/gis/geoip2/base.pyi b/django-stubs/contrib/gis/geoip2/base.pyi index 90b84ccb9..8b4884238 100644 --- a/django-stubs/contrib/gis/geoip2/base.pyi +++ b/django-stubs/contrib/gis/geoip2/base.pyi @@ -14,7 +14,7 @@ class GeoIP2: MODE_MMAP: int MODE_FILE: int MODE_MEMORY: int - cache_options: frozenset + cache_options: frozenset[int] def __init__( self, path: Path | str | None = ..., cache: int = ..., country: Any | None = ..., city: Any | None = ... ) -> None: ... diff --git a/django-stubs/contrib/gis/geos/collections.pyi b/django-stubs/contrib/gis/geos/collections.pyi index 585185a49..5a12c713d 100644 --- a/django-stubs/contrib/gis/geos/collections.pyi +++ b/django-stubs/contrib/gis/geos/collections.pyi @@ -9,8 +9,9 @@ class GeometryCollection(GEOSGeometry): def __iter__(self) -> Iterator[GEOSGeometry]: ... def __len__(self) -> int: ... @property - def tuple(self) -> tuple[Any]: ... - coords: tuple[Any] + def coords(self) -> tuple[Any, ...]: ... + @property + def tuple(self) -> tuple[Any, ...]: ... class MultiPoint(GeometryCollection): ... class MultiLineString(LinearGeometryMixin, GeometryCollection): ... diff --git a/django-stubs/contrib/gis/geos/coordseq.pyi b/django-stubs/contrib/gis/geos/coordseq.pyi index 6c9672510..4f9650fca 100644 --- a/django-stubs/contrib/gis/geos/coordseq.pyi +++ b/django-stubs/contrib/gis/geos/coordseq.pyi @@ -29,6 +29,6 @@ class GEOSCoordSeq(GEOSBase): @property def kml(self) -> str: ... @property - def tuple(self) -> tuple[Any]: ... + def tuple(self) -> tuple[Any, ...]: ... @property def is_counterclockwise(self) -> bool: ... diff --git a/django-stubs/contrib/gis/geos/factory.pyi b/django-stubs/contrib/gis/geos/factory.pyi index c4426dca4..5275963e5 100644 --- a/django-stubs/contrib/gis/geos/factory.pyi +++ b/django-stubs/contrib/gis/geos/factory.pyi @@ -1,6 +1,6 @@ -from typing import IO, Any +from typing import Any, BinaryIO, TextIO from django.contrib.gis.geos.geometry import GEOSGeometry -def fromfile(file_h: str | IO) -> GEOSGeometry: ... +def fromfile(file_h: str | TextIO | BinaryIO) -> GEOSGeometry: ... def fromstr(string: str, **kwargs: Any) -> GEOSGeometry: ... diff --git a/django-stubs/contrib/gis/geos/linestring.pyi b/django-stubs/contrib/gis/geos/linestring.pyi index cd59f4dd0..fde773cab 100644 --- a/django-stubs/contrib/gis/geos/linestring.pyi +++ b/django-stubs/contrib/gis/geos/linestring.pyi @@ -10,8 +10,9 @@ class LineString(LinearGeometryMixin, GEOSGeometry): def __iter__(self) -> Iterator[tuple[float, ...]]: ... def __len__(self) -> int: ... @property + def coords(self) -> tuple[tuple[float, ...]]: ... + @property def tuple(self) -> tuple[tuple[float, ...]]: ... - coords: tuple[tuple[float, ...]] @property def array(self) -> Any: ... @property diff --git a/django-stubs/contrib/gis/geos/point.pyi b/django-stubs/contrib/gis/geos/point.pyi index 668bf00e7..cdc40d35d 100644 --- a/django-stubs/contrib/gis/geos/point.pyi +++ b/django-stubs/contrib/gis/geos/point.pyi @@ -23,7 +23,6 @@ class Point(GEOSGeometry): @z.setter def z(self, value: float) -> None: ... @property - def tuple(self) -> tuple[float, ...]: ... - @tuple.setter - def tuple(self, tup: Any) -> None: ... - coords: tuple[float, ...] + def coords(self) -> tuple[float, ...]: ... + @coords.setter + def coords(self, tup: Any) -> None: ... diff --git a/django-stubs/contrib/gis/geos/polygon.pyi b/django-stubs/contrib/gis/geos/polygon.pyi index f24f4cace..8e5a3898c 100644 --- a/django-stubs/contrib/gis/geos/polygon.pyi +++ b/django-stubs/contrib/gis/geos/polygon.pyi @@ -15,5 +15,6 @@ class Polygon(GEOSGeometry): exterior_ring: LinearRing shell: LinearRing @property + def coords(self) -> tuple[tuple[tuple[float, ...]]]: ... + @property def tuple(self) -> tuple[tuple[tuple[float, ...]]]: ... - coords: tuple[tuple[tuple[float, ...]]] diff --git a/django-stubs/contrib/gis/measure.pyi b/django-stubs/contrib/gis/measure.pyi index 16bacd9e9..422f5f3fe 100644 --- a/django-stubs/contrib/gis/measure.pyi +++ b/django-stubs/contrib/gis/measure.pyi @@ -22,7 +22,7 @@ class MeasureBase: def __isub__(self: Self, other: Self) -> Self: ... def __mul__(self, other: _NUMERIC_TYPES) -> Any: ... def __imul__(self: Self, other: _NUMERIC_TYPES) -> Self: ... - def __rmul__(self: Self, other: _NUMERIC_TYPES) -> Self: ... + def __rmul__(self: Self, other: Any) -> Self: ... def __truediv__(self: Self, other: _NUMERIC_TYPES) -> Self: ... def __itruediv__(self: Self, other: _NUMERIC_TYPES) -> Self: ... def __bool__(self) -> bool: ... diff --git a/django-stubs/contrib/gis/utils/layermapping.pyi b/django-stubs/contrib/gis/utils/layermapping.pyi index eb20798b3..ba7d8ab5e 100644 --- a/django-stubs/contrib/gis/utils/layermapping.pyi +++ b/django-stubs/contrib/gis/utils/layermapping.pyi @@ -27,7 +27,7 @@ class LayerMapping: source_srs: Any transform: Any encoding: str | None - unique: list | tuple | str | None + unique: list[str] | tuple[str, ...] | str | None transaction_mode: Any transaction_decorator: Any def __init__( @@ -40,7 +40,7 @@ class LayerMapping: encoding: str = ..., transaction_mode: str = ..., transform: bool = ..., - unique: list | tuple | str | None = ..., + unique: list[str] | tuple[str, ...] | str | None = ..., using: str | None = ..., ) -> None: ... def check_fid_range(self, fid_range: Any) -> Any: ... From 18b9b00fb2015650e08fca848d30270bfe3eff8b Mon Sep 17 00:00:00 2001 From: Taku Fukada Date: Mon, 26 Dec 2022 14:10:15 +0900 Subject: [PATCH 4/6] Replace IO with Protocol --- django-stubs/contrib/gis/geos/factory.pyi | 7 +++++-- django-stubs/contrib/gis/utils/layermapping.pyi | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/django-stubs/contrib/gis/geos/factory.pyi b/django-stubs/contrib/gis/geos/factory.pyi index 5275963e5..1328ef998 100644 --- a/django-stubs/contrib/gis/geos/factory.pyi +++ b/django-stubs/contrib/gis/geos/factory.pyi @@ -1,6 +1,9 @@ -from typing import Any, BinaryIO, TextIO +from typing import Any, Protocol from django.contrib.gis.geos.geometry import GEOSGeometry -def fromfile(file_h: str | TextIO | BinaryIO) -> GEOSGeometry: ... +class _Reader(Protocol): + def read(self) -> str | bytes: ... + +def fromfile(file_h: str | _Reader) -> GEOSGeometry: ... def fromstr(string: str, **kwargs: Any) -> GEOSGeometry: ... diff --git a/django-stubs/contrib/gis/utils/layermapping.pyi b/django-stubs/contrib/gis/utils/layermapping.pyi index ba7d8ab5e..ad0cbb92b 100644 --- a/django-stubs/contrib/gis/utils/layermapping.pyi +++ b/django-stubs/contrib/gis/utils/layermapping.pyi @@ -1,6 +1,6 @@ from collections.abc import Mapping from pathlib import Path -from typing import Any, TextIO +from typing import Any, Protocol from django.contrib.gis.gdal import DataSource, OGRGeomType from django.contrib.gis.gdal.field import Field as OGRField @@ -14,6 +14,9 @@ class InvalidDecimal(LayerMapError): ... class InvalidInteger(LayerMapError): ... class MissingForeignKey(LayerMapError): ... +class _Writer(Protocol): + def write(self, __s: str) -> Any: ... + class LayerMapping: MULTI_TYPES: dict[int, OGRGeomType] FIELD_TYPES: dict[Field, OGRField | tuple[OGRField, ...]] @@ -65,6 +68,6 @@ class LayerMapping: step: bool = ..., progress: bool = ..., silent: bool = ..., - stream: TextIO = ..., + stream: _Writer = ..., strict: bool = ..., ) -> Any: ... From b7858ad5d4461cd161bca5652546760436119e9f Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Wed, 4 Jan 2023 15:23:38 +0200 Subject: [PATCH 5/6] Fix flake8 / revert unnecessary churn --- django-stubs/contrib/gis/gdal/geometries.pyi | 2 -- django-stubs/contrib/gis/geos/geometry.pyi | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index 86ed3cf25..ecb261bd6 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -4,8 +4,6 @@ from django.contrib.gis.gdal import CoordTransform, SpatialReference from django.contrib.gis.gdal.base import GDALBase as GDALBase from django.contrib.gis.gdal.envelope import Envelope as Envelope from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType -from django.contrib.gis.gdal.srs import CoordTransform as CoordTransform -from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference from django.contrib.gis.geos import GEOSGeometry class OGRGeometry(GDALBase): diff --git a/django-stubs/contrib/gis/geos/geometry.pyi b/django-stubs/contrib/gis/geos/geometry.pyi index e014ee077..21e507c92 100644 --- a/django-stubs/contrib/gis/geos/geometry.pyi +++ b/django-stubs/contrib/gis/geos/geometry.pyi @@ -1,8 +1,8 @@ from typing import Any from _typeshed import Self +from django.contrib.gis.gdal import CoordTransform, SpatialReference from django.contrib.gis.gdal.geometries import OGRGeometry -from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference from django.contrib.gis.geometry import hex_regex as hex_regex # noqa: F401 from django.contrib.gis.geometry import json_regex as json_regex from django.contrib.gis.geometry import wkt_regex as wkt_regex From 58b608ca6af098d71902b3082029ba60a4a62a25 Mon Sep 17 00:00:00 2001 From: Taku Fukada Date: Wed, 4 Jan 2023 23:40:57 +0900 Subject: [PATCH 6/6] Remove unneccesory re-exports --- django-stubs/contrib/gis/admin/options.pyi | 2 +- django-stubs/contrib/gis/apps.pyi | 2 +- django-stubs/contrib/gis/gdal/datasource.pyi | 6 +++--- django-stubs/contrib/gis/gdal/driver.pyi | 2 +- django-stubs/contrib/gis/gdal/feature.pyi | 8 ++++---- django-stubs/contrib/gis/gdal/field.pyi | 2 +- django-stubs/contrib/gis/gdal/geometries.pyi | 6 +++--- django-stubs/contrib/gis/gdal/layer.pyi | 16 ++++++++-------- django-stubs/contrib/gis/gdal/raster/band.pyi | 2 +- django-stubs/contrib/gis/gdal/raster/base.pyi | 2 +- django-stubs/contrib/gis/gdal/raster/source.pyi | 8 ++++---- django-stubs/contrib/gis/gdal/srs.pyi | 2 +- django-stubs/contrib/gis/geos/collections.pyi | 3 +-- django-stubs/contrib/gis/geos/coordseq.pyi | 2 +- django-stubs/contrib/gis/geos/geometry.pyi | 9 ++++----- django-stubs/contrib/gis/geos/linestring.pyi | 3 +-- django-stubs/contrib/gis/geos/point.pyi | 2 +- django-stubs/contrib/gis/geos/polygon.pyi | 4 ++-- django-stubs/contrib/gis/geos/prepared.pyi | 4 ++-- 19 files changed, 41 insertions(+), 44 deletions(-) diff --git a/django-stubs/contrib/gis/admin/options.pyi b/django-stubs/contrib/gis/admin/options.pyi index 34ebd9ecc..a8e014c94 100644 --- a/django-stubs/contrib/gis/admin/options.pyi +++ b/django-stubs/contrib/gis/admin/options.pyi @@ -1,6 +1,6 @@ from typing import Any -from django.contrib.admin import ModelAdmin as ModelAdmin +from django.contrib.admin import ModelAdmin from django.contrib.gis.forms import BaseGeometryWidget spherical_mercator_srid: int diff --git a/django-stubs/contrib/gis/apps.pyi b/django-stubs/contrib/gis/apps.pyi index a169c0be3..ffef1b725 100644 --- a/django-stubs/contrib/gis/apps.pyi +++ b/django-stubs/contrib/gis/apps.pyi @@ -1,3 +1,3 @@ -from django.apps import AppConfig as AppConfig +from django.apps import AppConfig class GISConfig(AppConfig): ... diff --git a/django-stubs/contrib/gis/gdal/datasource.pyi b/django-stubs/contrib/gis/gdal/datasource.pyi index c54faed30..aaaf621ed 100644 --- a/django-stubs/contrib/gis/gdal/datasource.pyi +++ b/django-stubs/contrib/gis/gdal/datasource.pyi @@ -1,8 +1,8 @@ from typing import Any -from django.contrib.gis.gdal.base import GDALBase as GDALBase -from django.contrib.gis.gdal.driver import Driver as Driver -from django.contrib.gis.gdal.layer import Layer as Layer +from django.contrib.gis.gdal.base import GDALBase +from django.contrib.gis.gdal.driver import Driver +from django.contrib.gis.gdal.layer import Layer class DataSource(GDALBase): destructor: Any diff --git a/django-stubs/contrib/gis/gdal/driver.pyi b/django-stubs/contrib/gis/gdal/driver.pyi index c94ad3b59..504a59902 100644 --- a/django-stubs/contrib/gis/gdal/driver.pyi +++ b/django-stubs/contrib/gis/gdal/driver.pyi @@ -1,6 +1,6 @@ from typing import Any -from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.base import GDALBase class Driver(GDALBase): ptr: Any diff --git a/django-stubs/contrib/gis/gdal/feature.pyi b/django-stubs/contrib/gis/gdal/feature.pyi index 3bff413fa..7fe283b00 100644 --- a/django-stubs/contrib/gis/gdal/feature.pyi +++ b/django-stubs/contrib/gis/gdal/feature.pyi @@ -1,9 +1,9 @@ from typing import Any -from django.contrib.gis.gdal.base import GDALBase as GDALBase -from django.contrib.gis.gdal.field import Field as Field -from django.contrib.gis.gdal.geometries import OGRGeometry as OGRGeometry -from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType +from django.contrib.gis.gdal.base import GDALBase +from django.contrib.gis.gdal.field import Field +from django.contrib.gis.gdal.geometries import OGRGeometry +from django.contrib.gis.gdal.geomtype import OGRGeomType class Feature(GDALBase): destructor: Any diff --git a/django-stubs/contrib/gis/gdal/field.pyi b/django-stubs/contrib/gis/gdal/field.pyi index 0c5ac2400..6d1a27a3b 100644 --- a/django-stubs/contrib/gis/gdal/field.pyi +++ b/django-stubs/contrib/gis/gdal/field.pyi @@ -1,6 +1,6 @@ from typing import Any -from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.base import GDALBase class Field(GDALBase): ptr: Any diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index ecb261bd6..d55a0aa73 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -1,9 +1,9 @@ from typing import Any, AnyStr from django.contrib.gis.gdal import CoordTransform, SpatialReference -from django.contrib.gis.gdal.base import GDALBase as GDALBase -from django.contrib.gis.gdal.envelope import Envelope as Envelope -from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType +from django.contrib.gis.gdal.base import GDALBase +from django.contrib.gis.gdal.envelope import Envelope +from django.contrib.gis.gdal.geomtype import OGRGeomType from django.contrib.gis.geos import GEOSGeometry class OGRGeometry(GDALBase): diff --git a/django-stubs/contrib/gis/gdal/layer.pyi b/django-stubs/contrib/gis/gdal/layer.pyi index 7d2e7d929..61536322f 100644 --- a/django-stubs/contrib/gis/gdal/layer.pyi +++ b/django-stubs/contrib/gis/gdal/layer.pyi @@ -1,14 +1,14 @@ from collections.abc import Iterator from typing import Any, AnyStr, overload -from django.contrib.gis.gdal.base import GDALBase as GDALBase -from django.contrib.gis.gdal.envelope import Envelope as Envelope -from django.contrib.gis.gdal.feature import Feature as Feature -from django.contrib.gis.gdal.field import Field as Field -from django.contrib.gis.gdal.geometries import OGRGeometry as OGRGeometry -from django.contrib.gis.gdal.geomtype import OGRGeomType as OGRGeomType -from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference -from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry +from django.contrib.gis.gdal.base import GDALBase +from django.contrib.gis.gdal.envelope import Envelope +from django.contrib.gis.gdal.feature import Feature +from django.contrib.gis.gdal.field import Field +from django.contrib.gis.gdal.geometries import OGRGeometry +from django.contrib.gis.gdal.geomtype import OGRGeomType +from django.contrib.gis.gdal.srs import SpatialReference +from django.contrib.gis.geos.geometry import GEOSGeometry from typing_extensions import Literal class Layer(GDALBase): diff --git a/django-stubs/contrib/gis/gdal/raster/band.pyi b/django-stubs/contrib/gis/gdal/raster/band.pyi index e5469b4ee..590b600f4 100644 --- a/django-stubs/contrib/gis/gdal/raster/band.pyi +++ b/django-stubs/contrib/gis/gdal/raster/band.pyi @@ -1,6 +1,6 @@ from typing import Any, overload -from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase +from django.contrib.gis.gdal.raster.base import GDALRasterBase from typing_extensions import Literal class GDALBand(GDALRasterBase): diff --git a/django-stubs/contrib/gis/gdal/raster/base.pyi b/django-stubs/contrib/gis/gdal/raster/base.pyi index fabfebf44..3850e028f 100644 --- a/django-stubs/contrib/gis/gdal/raster/base.pyi +++ b/django-stubs/contrib/gis/gdal/raster/base.pyi @@ -1,6 +1,6 @@ from typing import Any -from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.base import GDALBase class GDALRasterBase(GDALBase): @property diff --git a/django-stubs/contrib/gis/gdal/raster/source.pyi b/django-stubs/contrib/gis/gdal/raster/source.pyi index a66e4676c..fb3dbffdb 100644 --- a/django-stubs/contrib/gis/gdal/raster/source.pyi +++ b/django-stubs/contrib/gis/gdal/raster/source.pyi @@ -1,10 +1,10 @@ from collections.abc import Sequence from typing import Any -from django.contrib.gis.gdal.driver import Driver as Driver -from django.contrib.gis.gdal.raster.band import BandList as BandList -from django.contrib.gis.gdal.raster.base import GDALRasterBase as GDALRasterBase -from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference +from django.contrib.gis.gdal.driver import Driver +from django.contrib.gis.gdal.raster.band import BandList +from django.contrib.gis.gdal.raster.base import GDALRasterBase +from django.contrib.gis.gdal.srs import SpatialReference class TransformPoint(list[Sequence[float]]): indices: dict[str, tuple[int, int]] diff --git a/django-stubs/contrib/gis/gdal/srs.pyi b/django-stubs/contrib/gis/gdal/srs.pyi index 14f597848..e7ba613cd 100644 --- a/django-stubs/contrib/gis/gdal/srs.pyi +++ b/django-stubs/contrib/gis/gdal/srs.pyi @@ -2,7 +2,7 @@ from enum import IntEnum from typing import Any, AnyStr from _typeshed import Self -from django.contrib.gis.gdal.base import GDALBase as GDALBase +from django.contrib.gis.gdal.base import GDALBase class AxisOrder(IntEnum): TRADITIONAL: int diff --git a/django-stubs/contrib/gis/geos/collections.pyi b/django-stubs/contrib/gis/geos/collections.pyi index 5a12c713d..afa14c181 100644 --- a/django-stubs/contrib/gis/geos/collections.pyi +++ b/django-stubs/contrib/gis/geos/collections.pyi @@ -1,8 +1,7 @@ from collections.abc import Iterator from typing import Any -from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry -from django.contrib.gis.geos.geometry import LinearGeometryMixin as LinearGeometryMixin +from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin class GeometryCollection(GEOSGeometry): def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/gis/geos/coordseq.pyi b/django-stubs/contrib/gis/geos/coordseq.pyi index 4f9650fca..94b8976d6 100644 --- a/django-stubs/contrib/gis/geos/coordseq.pyi +++ b/django-stubs/contrib/gis/geos/coordseq.pyi @@ -2,7 +2,7 @@ from collections.abc import Iterator from typing import Any from _typeshed import Self -from django.contrib.gis.geos.base import GEOSBase as GEOSBase +from django.contrib.gis.geos.base import GEOSBase class GEOSCoordSeq(GEOSBase): ptr_type: Any diff --git a/django-stubs/contrib/gis/geos/geometry.pyi b/django-stubs/contrib/gis/geos/geometry.pyi index 21e507c92..460d906a4 100644 --- a/django-stubs/contrib/gis/geos/geometry.pyi +++ b/django-stubs/contrib/gis/geos/geometry.pyi @@ -4,13 +4,12 @@ from _typeshed import Self from django.contrib.gis.gdal import CoordTransform, SpatialReference from django.contrib.gis.gdal.geometries import OGRGeometry from django.contrib.gis.geometry import hex_regex as hex_regex # noqa: F401 -from django.contrib.gis.geometry import json_regex as json_regex from django.contrib.gis.geometry import wkt_regex as wkt_regex -from django.contrib.gis.geos.base import GEOSBase as GEOSBase -from django.contrib.gis.geos.coordseq import GEOSCoordSeq as GEOSCoordSeq -from django.contrib.gis.geos.mutable_list import ListMixin as ListMixin +from django.contrib.gis.geos.base import GEOSBase +from django.contrib.gis.geos.coordseq import GEOSCoordSeq +from django.contrib.gis.geos.mutable_list import ListMixin from django.contrib.gis.geos.point import Point -from django.contrib.gis.geos.prepared import PreparedGeometry as PreparedGeometry +from django.contrib.gis.geos.prepared import PreparedGeometry class GEOSGeometryBase(GEOSBase): ptr_type: Any diff --git a/django-stubs/contrib/gis/geos/linestring.pyi b/django-stubs/contrib/gis/geos/linestring.pyi index fde773cab..d7a6fc614 100644 --- a/django-stubs/contrib/gis/geos/linestring.pyi +++ b/django-stubs/contrib/gis/geos/linestring.pyi @@ -1,8 +1,7 @@ from collections.abc import Iterator from typing import Any -from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry -from django.contrib.gis.geos.geometry import LinearGeometryMixin as LinearGeometryMixin +from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin class LineString(LinearGeometryMixin, GEOSGeometry): has_cs: bool diff --git a/django-stubs/contrib/gis/geos/point.pyi b/django-stubs/contrib/gis/geos/point.pyi index cdc40d35d..791fe202f 100644 --- a/django-stubs/contrib/gis/geos/point.pyi +++ b/django-stubs/contrib/gis/geos/point.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterator from typing import Any -from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry +from django.contrib.gis.geos.geometry import GEOSGeometry class Point(GEOSGeometry): has_cs: bool diff --git a/django-stubs/contrib/gis/geos/polygon.pyi b/django-stubs/contrib/gis/geos/polygon.pyi index 8e5a3898c..4d818e015 100644 --- a/django-stubs/contrib/gis/geos/polygon.pyi +++ b/django-stubs/contrib/gis/geos/polygon.pyi @@ -1,8 +1,8 @@ from collections.abc import Iterator from typing import Any -from django.contrib.gis.geos.geometry import GEOSGeometry as GEOSGeometry -from django.contrib.gis.geos.linestring import LinearRing as LinearRing +from django.contrib.gis.geos.geometry import GEOSGeometry +from django.contrib.gis.geos.linestring import LinearRing class Polygon(GEOSGeometry): def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/gis/geos/prepared.pyi b/django-stubs/contrib/gis/geos/prepared.pyi index b6f6e4247..f71ea3b97 100644 --- a/django-stubs/contrib/gis/geos/prepared.pyi +++ b/django-stubs/contrib/gis/geos/prepared.pyi @@ -1,7 +1,7 @@ from typing import Any -from .base import GEOSBase as GEOSBase -from .geometry import GEOSGeometry as GEOSGeometry +from .base import GEOSBase +from .geometry import GEOSGeometry class PreparedGeometry(GEOSBase): ptr_type: Any