From 46fd9b4dd6833de9dce8a533335af0aa2dd58068 Mon Sep 17 00:00:00 2001 From: Mattias Jakobsson Date: Wed, 16 Nov 2022 17:45:09 +0100 Subject: [PATCH 1/4] Make SpatialReference accept int --- django-stubs/contrib/gis/gdal/srs.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-stubs/contrib/gis/gdal/srs.pyi b/django-stubs/contrib/gis/gdal/srs.pyi index cb298d363..dad5cfa0b 100644 --- a/django-stubs/contrib/gis/gdal/srs.pyi +++ b/django-stubs/contrib/gis/gdal/srs.pyi @@ -11,7 +11,7 @@ class SpatialReference(GDALBase): destructor: Any axis_order: Any ptr: Any - def __init__(self, srs_input: str = ..., srs_type: str = ..., axis_order: Any | None = ...) -> None: ... + def __init__(self, srs_input: str | int = ..., 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: ... From e7eaa7b78413eb8e1c17e2aabe0001cb8a32940c Mon Sep 17 00:00:00 2001 From: Mattias Jakobsson Date: Wed, 16 Nov 2022 17:47:55 +0100 Subject: [PATCH 2/4] Make CoordTransform only accept SpatialReference --- django-stubs/contrib/gis/gdal/srs.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-stubs/contrib/gis/gdal/srs.pyi b/django-stubs/contrib/gis/gdal/srs.pyi index dad5cfa0b..cfac30a7b 100644 --- a/django-stubs/contrib/gis/gdal/srs.pyi +++ b/django-stubs/contrib/gis/gdal/srs.pyi @@ -64,4 +64,4 @@ class SpatialReference(GDALBase): class CoordTransform(GDALBase): destructor: Any ptr: Any - def __init__(self, source: Any, target: Any) -> None: ... + def __init__(self, source: SpatialReference, target: SpatialReference) -> None: ... From a7690a2ce27e12e63cba30537f41239db6e1f3c3 Mon Sep 17 00:00:00 2001 From: Mattias Jakobsson Date: Wed, 16 Nov 2022 18:18:06 +0100 Subject: [PATCH 3/4] Narrow OGRGeometry.transform's accepted types --- django-stubs/contrib/gis/gdal/geometries.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django-stubs/contrib/gis/gdal/geometries.pyi b/django-stubs/contrib/gis/gdal/geometries.pyi index 409ea5e89..a9f3927ae 100644 --- a/django-stubs/contrib/gis/gdal/geometries.pyi +++ b/django-stubs/contrib/gis/gdal/geometries.pyi @@ -1,5 +1,6 @@ from typing import Any +from django.contrib.gis.gdal import CoordTransform, SpatialReference from django.contrib.gis.gdal.base import GDALBase as GDALBase class OGRGeometry(GDALBase): @@ -63,7 +64,7 @@ class OGRGeometry(GDALBase): def ewkt(self) -> Any: ... def clone(self) -> Any: ... def close_rings(self) -> None: ... - def transform(self, coord_trans: Any, clone: bool = ...) -> Any: ... + def transform(self, coord_trans: CoordTransform | SpatialReference | str | int, clone: bool = ...) -> Any: ... def intersects(self, other: Any) -> Any: ... def equals(self, other: Any) -> Any: ... def disjoint(self, other: Any) -> Any: ... From 2d33d68a0488a8d9b823918e9b21ddd1d03ceff8 Mon Sep 17 00:00:00 2001 From: Mattias Jakobsson Date: Wed, 16 Nov 2022 19:25:26 +0100 Subject: [PATCH 4/4] Narrow GEOSGeometryBase.transform's accepted types --- django-stubs/contrib/gis/geos/geometry.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django-stubs/contrib/gis/geos/geometry.pyi b/django-stubs/contrib/gis/geos/geometry.pyi index bd64571cd..0d68ce5c3 100644 --- a/django-stubs/contrib/gis/geos/geometry.pyi +++ b/django-stubs/contrib/gis/geos/geometry.pyi @@ -1,6 +1,7 @@ from typing import Any, TypeVar from _typeshed import Self +from django.contrib.gis.gdal 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 @@ -92,7 +93,7 @@ class GEOSGeometryBase(GEOSBase): @property def crs(self) -> Any: ... ptr: Any - def transform(self, ct: Any, clone: bool = ...) -> Any: ... + def transform(self, ct: CoordTransform | SpatialReference | str | int, clone: bool = ...) -> Any: ... @property def boundary(self) -> Any: ... def buffer(self, width: Any, quadsegs: int = ...) -> Any: ...