From 737d469f64267efe7721b85d5bc940995781bc75 Mon Sep 17 00:00:00 2001 From: Ali Hamdan Date: Sat, 13 Dec 2025 15:15:32 +0100 Subject: [PATCH 1/3] geopandas: unpin pandas-stubs --- stubs/geopandas/METADATA.toml | 2 +- stubs/geopandas/geopandas/array.pyi | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/stubs/geopandas/METADATA.toml b/stubs/geopandas/METADATA.toml index 6b64967fa567..97cd71db2c18 100644 --- a/stubs/geopandas/METADATA.toml +++ b/stubs/geopandas/METADATA.toml @@ -1,6 +1,6 @@ version = "1.1.1" # Requires a version of numpy with a `py.typed` file -requires = ["numpy>=1.20", "pandas-stubs<2.3.3.251201", "types-shapely", "pyproj"] +requires = ["numpy>=1.20", "pandas-stubs", "types-shapely", "pyproj"] upstream_repository = "https://github.com/geopandas/geopandas" [tool.stubtest] diff --git a/stubs/geopandas/geopandas/array.pyi b/stubs/geopandas/geopandas/array.pyi index 7572dd5b5c48..ca9596b43cdf 100644 --- a/stubs/geopandas/geopandas/array.pyi +++ b/stubs/geopandas/geopandas/array.pyi @@ -1,12 +1,13 @@ import builtins from _typeshed import Incomplete, Unused -from collections.abc import Callable, Collection, Sequence +from collections.abc import Callable, Collection from typing import Any, ClassVar, Final, Literal, NoReturn, SupportsIndex, TypeVar, overload from typing_extensions import Self, TypeAlias, deprecated import numpy as np import pandas as pd from numpy.typing import ArrayLike, DTypeLike, NDArray +from pandas._typing import ScalarIndexer, SequenceIndexer, TakeIndexer from pandas.api.extensions import ExtensionArray, ExtensionDtype from pyproj import CRS, Transformer from shapely import Geometry @@ -68,15 +69,9 @@ class GeometryArray(ExtensionArray): def __len__(self) -> int: ... # np.integer[Any] because precision is not important @overload - def __getitem__(self, idx: int | np.integer[Any]) -> BaseGeometry: ... # Always 1-D, doesn't accept tuple + def __getitem__(self, idx: ScalarIndexer) -> BaseGeometry: ... # Always 1-D, doesn't accept tuple @overload - def __getitem__( - self, idx: slice | Sequence[SupportsIndex] | NDArray[np.bool_] | NDArray[np.integer[Any]] - ) -> GeometryArray: ... - @overload - def __getitem__( - self, idx: int | np.integer[Any] | slice | Sequence[int] | NDArray[np.bool_] | NDArray[np.integer[Any]] - ) -> BaseGeometry | GeometryArray: ... + def __getitem__(self, idx: SequenceIndexer) -> GeometryArray: ... def __setitem__( self, key, value: _ArrayOrGeom | pd.DataFrame | pd.Series[Any] # Cannot use pd.Series[BaseGeometry] ) -> None: ... @@ -222,17 +217,15 @@ class GeometryArray(ExtensionArray): @property def ndim(self) -> Literal[1]: ... def copy(self, *args: Unused, **kwargs: Unused) -> GeometryArray: ... - def take( - self, indices: Sequence[SupportsIndex] | NDArray[np.integer], allow_fill: bool = False, fill_value: Geometry | None = None - ) -> GeometryArray: ... - def fillna( + def take(self, indices: TakeIndexer, allow_fill: bool = False, fill_value: Geometry | None = None) -> GeometryArray: ... + def fillna( # type: ignore[override] self, value: Geometry | GeometryArray | None = None, method: Literal["backfill", "bfill", "pad", "ffill"] | None = None, limit: int | None = None, copy: bool = True, ) -> GeometryArray: ... - @overload + @overload # type: ignore[override] def astype(self, dtype: GeometryDtype, copy: bool = True) -> GeometryArray: ... @overload def astype(self, dtype: ExtensionDtype | Literal["string"], copy: bool = True) -> ExtensionArray: ... # type: ignore[overload-overlap] From bbf40ffe6c1f46a7e6e80729110cff9420c78538 Mon Sep 17 00:00:00 2001 From: Ali Hamdan Date: Sat, 13 Dec 2025 19:18:14 +0100 Subject: [PATCH 2/3] Add lower bound for pandas-stubs --- stubs/geopandas/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/geopandas/METADATA.toml b/stubs/geopandas/METADATA.toml index 97cd71db2c18..7aca0aa6c412 100644 --- a/stubs/geopandas/METADATA.toml +++ b/stubs/geopandas/METADATA.toml @@ -1,6 +1,6 @@ version = "1.1.1" # Requires a version of numpy with a `py.typed` file -requires = ["numpy>=1.20", "pandas-stubs", "types-shapely", "pyproj"] +requires = ["numpy>=1.20", "pandas-stubs>=2.1.4", "types-shapely", "pyproj"] upstream_repository = "https://github.com/geopandas/geopandas" [tool.stubtest] From 869dcaeac38c1cc2d29464f06bb2bb881e67ffac Mon Sep 17 00:00:00 2001 From: Ali Hamdan Date: Sat, 13 Dec 2025 19:27:19 +0100 Subject: [PATCH 3/3] Revert "Add lower bound for pandas-stubs" This reverts commit bbf40ffe6c1f46a7e6e80729110cff9420c78538. --- stubs/geopandas/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/geopandas/METADATA.toml b/stubs/geopandas/METADATA.toml index 7aca0aa6c412..97cd71db2c18 100644 --- a/stubs/geopandas/METADATA.toml +++ b/stubs/geopandas/METADATA.toml @@ -1,6 +1,6 @@ version = "1.1.1" # Requires a version of numpy with a `py.typed` file -requires = ["numpy>=1.20", "pandas-stubs>=2.1.4", "types-shapely", "pyproj"] +requires = ["numpy>=1.20", "pandas-stubs", "types-shapely", "pyproj"] upstream_repository = "https://github.com/geopandas/geopandas" [tool.stubtest]