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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stubs/shapely/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ shapely\.conftest
shapely\.tests.*

shapely\._typing # stubs only module
shapely\.lib\..*_scalar # internal fast paths
5 changes: 3 additions & 2 deletions stubs/shapely/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = "2.1.*"
version = "2.2.*"
upstream-repository = "https://github.com/shapely/shapely"
# Requires a version of numpy with a `py.typed` file
dependencies = ["numpy>=1.20"]
dependencies = ["numpy>=1.26"]
requires-python = ">=3.11"
11 changes: 9 additions & 2 deletions stubs/shapely/shapely/_coverage.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
from typing import overload
from typing import Literal, overload

import numpy as np

from ._typing import ArrayLike, GeoArray, GeoArrayLikeSeq, OptGeoArrayLike
from .geometry import Polygon

__all__ = ["coverage_invalid_edges", "coverage_is_valid", "coverage_simplify"]
__all__ = ["coverage_clean", "coverage_invalid_edges", "coverage_is_valid", "coverage_simplify"]

def coverage_clean(
geometry: OptGeoArrayLike,
*,
gap_width: float = 0.0,
snapping_distance: float = -1,
merge_strategy: Literal["longest_border", "max_area", "min_area", "min_index"] | int = "longest_border",
) -> GeoArray: ...
Comment thread
jack-volantautonomy marked this conversation as resolved.
Resolved
def coverage_is_valid(geometry: OptGeoArrayLike, gap_width: float = 0.0, **kwargs) -> np.bool_: ...
def coverage_invalid_edges(geometry: OptGeoArrayLike, gap_width: float = 0.0, **kwargs) -> GeoArray: ...

Expand Down
2 changes: 2 additions & 0 deletions stubs/shapely/shapely/_enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ from enum import IntEnum
class ParamEnum(IntEnum): # type: ignore[misc] # Enum with no members
@classmethod
def get_value(cls, item: str) -> int: ...
@classmethod
def has_value(cls, value: int) -> bool: ...
14 changes: 14 additions & 0 deletions stubs/shapely/shapely/_geometry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ __all__ = [
"get_point",
"get_precision",
"get_rings",
"get_segments",
"get_srid",
"get_type_id",
"get_x",
Expand Down Expand Up @@ -184,6 +185,19 @@ def get_precision(geometry: Geometry | None, **kwargs) -> np.float64: ...
@overload
def get_precision(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...

@overload
def get_segments(
geometry: OptGeoArrayLike, *, include_z: bool = False, return_index: Literal[False] = False, **kwargs
) -> GeoArray: ...
@overload
def get_segments(
geometry: OptGeoArrayLike, *, include_z: bool = False, return_index: Literal[True], **kwargs
) -> tuple[GeoArray, NDArray[np.int64]]: ...
@overload
def get_segments(
geometry: OptGeoArrayLike, *, include_z: bool = False, return_index: bool, **kwargs
) -> GeoArray | tuple[GeoArray, NDArray[np.int64]]: ...

class SetPrecisionMode(ParamEnum):
valid_output = 0
pointwise = 1
Expand Down
7 changes: 1 addition & 6 deletions stubs/shapely/shapely/_version.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
from typing import TypedDict

version_json: str
_Versions = TypedDict("_Versions", {"date": str, "dirty": bool, "error": None, "full-revisionid": str, "version": str})

def get_versions() -> _Versions: ...
__git_version__: str
18 changes: 18 additions & 0 deletions stubs/shapely/shapely/constructive.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ __all__ = [
"minimum_bounding_circle",
"minimum_clearance_line",
"minimum_rotated_rectangle",
"minimum_width",
"node",
"normalize",
"offset_curve",
Expand All @@ -40,6 +41,7 @@ __all__ = [
"segmentize",
"simplify",
"snap",
"split",
"voronoi_polygons",
]

Expand Down Expand Up @@ -452,6 +454,13 @@ def snap(
geometry: OptGeoArrayLike, reference: OptGeoArrayLike, tolerance: ArrayLikeSeq[float], **kwargs: Unpack[UFuncKwargs]
) -> GeoArray: ...

@overload
def split(geometry: OptGeoArrayLikeSeq, splitter: OptGeoArrayLike, **kwargs: Unpack[UFuncKwargs]) -> GeoArray: ...
@overload
def split(geometry: OptGeoArrayLike, splitter: OptGeoArrayLikeSeq, **kwargs: Unpack[UFuncKwargs]) -> GeoArray: ...
@overload
def split(geometry: Geometry, splitter: Geometry, **kwargs: Unpack[UFuncKwargs]) -> GeometryCollection: ...

@overload
def voronoi_polygons(
geometry: Geometry,
Expand Down Expand Up @@ -609,6 +618,15 @@ def minimum_bounding_circle(geometry: Geometry | None, **kwargs: Unpack[UFuncKwa
@overload
def minimum_bounding_circle(geometry: OptGeoArrayLikeSeq, **kwargs: Unpack[UFuncKwargs]) -> GeoArray: ...

@overload
def minimum_width(geometry: Geometry, **kwargs: Unpack[UFuncKwargs]) -> LineString: ...
@overload
def minimum_width(geometry: None, **kwargs: Unpack[UFuncKwargs]) -> None: ...
@overload
def minimum_width(geometry: OptGeoArrayLikeSeq, **kwargs: Unpack[UFuncKwargs]) -> GeoArray: ...
@overload
def minimum_width(geometry: Geometry | None, **kwargs: Unpack[UFuncKwargs]) -> LineString | None: ...

@overload
def maximum_inscribed_circle(
geometry: Polygon | MultiPolygon, tolerance: float | None = None, **kwargs: Unpack[UFuncKwargs]
Expand Down
19 changes: 18 additions & 1 deletion stubs/shapely/shapely/coordinates.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from numpy.typing import NDArray

from ._typing import ArrayLikeSeq, GeoArray, GeoT, OptGeoArrayLike, OptGeoArrayLikeSeq, OptGeoT

__all__ = ["transform", "count_coordinates", "get_coordinates", "set_coordinates"]
__all__ = ["transform", "count_coordinates", "get_coordinates", "set_coordinates", "transform_coordseq"]

@overload
def transform(
Expand All @@ -25,6 +25,23 @@ def transform(
interleaved: bool = True,
) -> GeoArray: ...

@overload
def transform_coordseq(
geometry: OptGeoT,
transformation: Callable[[NDArray[np.float64]], NDArray[np.float64]],
*,
include_z: bool | None = False,
interleaved: bool = True,
) -> OptGeoT: ...
@overload
def transform_coordseq(
geometry: OptGeoArrayLikeSeq,
transformation: Callable[[NDArray[np.float64]], NDArray[np.float64]],
*,
include_z: bool | None = False,
interleaved: bool = True,
) -> GeoArray: ...

def count_coordinates(geometry: OptGeoArrayLike) -> int: ...

@overload
Expand Down
4 changes: 2 additions & 2 deletions stubs/shapely/shapely/creation.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ def geometrycollections(
**kwargs: Unpack[UFuncKwargsNoOut],
) -> GeometryCollection | GeoArray: ...

def prepare(geometry: OptGeoArrayLike, **kwargs: Unpack[UFuncKwargsNoOut]) -> None: ...
def destroy_prepared(geometry: OptGeoArrayLike, **kwargs: Unpack[UFuncKwargsNoOut]) -> None: ...
def prepare(geometry: OptGeoArrayLike, **kwargs: Unpack[UFuncKwargsNoOut]) -> bool: ...
def destroy_prepared(geometry: OptGeoArrayLike, **kwargs: Unpack[UFuncKwargsNoOut]) -> bool: ...
def empty(
shape: SupportsIndex | Sequence[SupportsIndex], geom_type: GeometryType | int | None = None, order: Literal["C", "F"] = "C"
) -> NDArray[np.object_]: ...
2 changes: 2 additions & 0 deletions stubs/shapely/shapely/decorators.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Callable, Container
from typing import TypeVar
from typing_extensions import deprecated

_F = TypeVar("_F", bound=Callable[..., object])

Expand All @@ -8,5 +9,6 @@ class requires_geos:
def __init__(self, version: str) -> None: ...
def __call__(self, func: _F) -> _F: ...

@deprecated("'multithreading_enabled' is deprecated and will be removed in a future version.")
def multithreading_enabled(func: _F) -> _F: ...
def deprecate_positional(should_be_kwargs: Container[str], category: type[Warning] = ...) -> Callable[..., object]: ...
5 changes: 2 additions & 3 deletions stubs/shapely/shapely/geometry/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class BaseGeometry(Geometry):
"Directly calling 'BaseGeometry()' is deprecated. To create an empty geometry, "
"use one of the subclasses instead, for example 'GeometryCollection()'."
)
def __new__(self) -> GeometryCollection: ...
def __new__(cls) -> GeometryCollection: ...
def __bool__(self) -> bool: ...
def __nonzero__(self) -> bool: ...
def __format__(self, format_spec: str) -> str: ...

@overload
Expand Down Expand Up @@ -323,4 +322,4 @@ class EmptyGeometry(BaseGeometry):
"The 'EmptyGeometry()' constructor is deprecated. Use one of the "
"geometry subclasses instead, for example 'GeometryCollection()'."
)
def __new__(self) -> GeometryCollection: ... # type: ignore[misc]
def __new__(cls) -> GeometryCollection: ... # type: ignore[misc]
4 changes: 2 additions & 2 deletions stubs/shapely/shapely/geometry/collection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class GeometryCollection(BaseMultipartGeometry[_GeoT_co]):

@overload
def __new__(
self, geoms: BaseMultipartGeometry[_GeoT_co] | GeometrySequence[BaseMultipartGeometry[_GeoT_co]] | Collection[_GeoT_co]
cls, geoms: BaseMultipartGeometry[_GeoT_co] | GeometrySequence[BaseMultipartGeometry[_GeoT_co]] | Collection[_GeoT_co]
) -> Self: ...
@overload
def __new__(self, geoms: OptGeoArrayLike = None) -> Self: ...
def __new__(cls, geoms: OptGeoArrayLike = None) -> Self: ...

# more precise base overrides
@property
Expand Down
2 changes: 1 addition & 1 deletion stubs/shapely/shapely/geometry/linestring.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _ConvertibleToLineString: TypeAlias = LineString | ArrayLikeSeq[float] | Iterabl

class LineString(BaseGeometry):
__slots__: list[str] = []
def __new__(self, coordinates: _ConvertibleToLineString | None = None) -> Self: ...
def __new__(cls, coordinates: _ConvertibleToLineString | None = None) -> Self: ...
def svg(self, scale_factor: float = 1.0, stroke_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
def offset_curve(
self,
Expand Down
2 changes: 1 addition & 1 deletion stubs/shapely/shapely/geometry/multilinestring.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ __all__ = ["MultiLineString"]

class MultiLineString(BaseMultipartGeometry[LineString]):
__slots__: list[str] = []
def __new__(self, lines: BaseMultipartGeometry | Collection[_ConvertibleToLineString] | None = None) -> Self: ...
def __new__(cls, lines: BaseMultipartGeometry | Collection[_ConvertibleToLineString] | None = None) -> Self: ...
def svg(self, scale_factor: float = 1.0, stroke_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
# more precise base overrides
@property
Expand Down
2 changes: 1 addition & 1 deletion stubs/shapely/shapely/geometry/multipoint.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MultiPoint(BaseMultipartGeometry[Point]):
# like np.ndarray, pd.Index, pd.Series, ...
# I went with Collection as false negatives seem better to me than false positives in this case
__slots__: list[str] = []
def __new__(self, points: MultiPoint | Collection[_PointLike] | None = None) -> Self: ...
def __new__(cls, points: MultiPoint | Collection[_PointLike] | None = None) -> Self: ...
def svg(self, scale_factor: float = 1.0, fill_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
# more precise base overrides
@property
Expand Down
2 changes: 1 addition & 1 deletion stubs/shapely/shapely/geometry/multipolygon.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __all__ = ["MultiPolygon"]
class MultiPolygon(BaseMultipartGeometry[Polygon]):
__slots__: list[str] = []
def __new__(
self,
cls,
polygons: (
BaseMultipartGeometry
| Collection[Polygon | tuple[_PolygonShellLike] | tuple[_PolygonShellLike, _PolygonHolesLike] | None]
Expand Down
8 changes: 4 additions & 4 deletions stubs/shapely/shapely/geometry/point.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class Point(BaseGeometry):
__slots__: list[str] = []

@overload # no args: empty point
def __new__(self) -> Self: ...
def __new__(cls) -> Self: ...
@overload # one arg: (x, y[, z]) tuple or a Point instance
def __new__(self, coords: _PointLike, /) -> Self: ...
def __new__(cls, coords: _PointLike, /) -> Self: ...
@overload # two args: (x, y) tuple
def __new__(self, x: float, y: float, /) -> Self: ...
def __new__(cls, x: float, y: float, /) -> Self: ...
@overload # three args: (x, y, z) tuple
def __new__(self, x: float, y: float, z: float, /) -> Self: ...
def __new__(cls, x: float, y: float, z: float, /) -> Self: ...

@property
def x(self) -> float: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/shapely/shapely/geometry/polygon.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _PolygonHolesLike: TypeAlias = Collection[_ConvertibleToLinearRing | None] | Non

class LinearRing(LineString):
__slots__: list[str] = []
def __new__(self, coordinates: _ConvertibleToLinearRing | None = None) -> Self: ...
def __new__(cls, coordinates: _ConvertibleToLinearRing | None = None) -> Self: ...
@property
def is_ccw(self) -> bool: ...
@property
Expand All @@ -33,7 +33,7 @@ class InteriorRingSequence:

class Polygon(BaseGeometry):
__slots__: list[str] = []
def __new__(self, shell: _PolygonShellLike = None, holes: _PolygonHolesLike = None) -> Self: ...
def __new__(cls, shell: _PolygonShellLike = None, holes: _PolygonHolesLike = None) -> Self: ...
@property
def exterior(self) -> LinearRing: ...
@property
Expand Down
3 changes: 2 additions & 1 deletion stubs/shapely/shapely/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ contains: np.ufunc
contains_properly: np.ufunc
contains_xy: np.ufunc
convex_hull: np.ufunc
coverage_clean: np.ufunc
coverage_invalid_edges: np.ufunc
coverage_is_valid: np.ufunc
coverage_simplify: np.ufunc
Expand Down Expand Up @@ -92,13 +93,13 @@ line_merge: np.ufunc
line_merge_directed: np.ufunc
linearrings: np.ufunc
linestrings: np.ufunc
make_valid: np.ufunc
make_valid_with_params: np.ufunc
maximum_inscribed_circle: np.ufunc
minimum_bounding_circle: np.ufunc
minimum_bounding_radius: np.ufunc
minimum_clearance: np.ufunc
minimum_clearance_line: np.ufunc
minimum_width: np.ufunc
node: np.ufunc
normalize: np.ufunc
offset_curve: np.ufunc
Expand Down
2 changes: 2 additions & 0 deletions stubs/shapely/shapely/ops.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Callable, Iterable
from typing import Any, Literal, overload
from typing_extensions import deprecated

from ._typing import GeoT, OptGeoArrayLike, SupportsGeoInterface
from .algorithms.polylabel import polylabel as polylabel
Expand Down Expand Up @@ -88,6 +89,7 @@ def validate(geom: Geometry) -> str: ...
@overload
def validate(geom: Geometry | None) -> str | None: ...

@deprecated("Function 'ops.transform' is deprecated. Use 'shapely.transform' or 'shapely.transform_coordseq' instead.")
def transform(func: Callable[[float, float, float | None], tuple[float, ...]], geom: GeoT) -> GeoT: ...
def nearest_points(g1: Geometry, g2: Geometry) -> tuple[Point, Point]: ...
def snap(g1: GeoT, g2: Geometry, tolerance: float) -> GeoT: ...
Expand Down
Loading