Skip to content

Commit

Permalink
Fixes for mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Dec 25, 2022
1 parent 976fb50 commit cb8f391
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 25 deletions.
9 changes: 6 additions & 3 deletions django-stubs/contrib/gis/gdal/geometries.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...]: ...
Expand All @@ -119,8 +120,9 @@ class Polygon(OGRGeometry):
def shell(self) -> OGRGeometry: ...
exterior_ring: OGRGeometry
@property
def coords(self) -> tuple[tuple[tuple[float]]]: ...
@property
def tuple(self) -> tuple[tuple[tuple[float]]]: ...
coords: tuple[tuple[tuple[float]]]
@property
def point_count(self) -> int: ...
@property
Expand All @@ -133,8 +135,9 @@ class GeometryCollection(OGRGeometry):
@property
def point_count(self) -> int: ...
@property
def coords(self) -> tuple[Any]: ...
@property
def tuple(self) -> tuple[Any]: ...
coords: tuple[Any]

class MultiPoint(GeometryCollection): ...
class MultiLineString(GeometryCollection): ...
Expand Down
3 changes: 2 additions & 1 deletion django-stubs/contrib/gis/gdal/layer.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
11 changes: 4 additions & 7 deletions django-stubs/contrib/gis/gdal/raster/band.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = ...,
Expand All @@ -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: ...
3 changes: 2 additions & 1 deletion django-stubs/contrib/gis/gdal/raster/source.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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

class TransformPoint(list):
class TransformPoint(list[Sequence[float]]):
indices: dict[str, tuple[int, int]]
def __init__(self, raster: GDALRaster, prop: str) -> None: ...
@property
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/gis/geoip2/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion django-stubs/contrib/gis/geos/collections.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class GeometryCollection(GEOSGeometry):
def __iter__(self) -> Iterator[GEOSGeometry]: ...
def __len__(self) -> int: ...
@property
def coords(self) -> tuple[Any]: ...
@property
def tuple(self) -> tuple[Any]: ...
coords: tuple[Any]

class MultiPoint(GeometryCollection): ...
class MultiLineString(LinearGeometryMixin, GeometryCollection): ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/gis/geos/factory.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
3 changes: 2 additions & 1 deletion django-stubs/contrib/gis/geos/linestring.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions django-stubs/contrib/gis/geos/point.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
3 changes: 2 additions & 1 deletion django-stubs/contrib/gis/geos/polygon.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...]]]
2 changes: 1 addition & 1 deletion django-stubs/contrib/gis/measure.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/gis/utils/layermapping.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand All @@ -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: ...
Expand Down

0 comments on commit cb8f391

Please sign in to comment.