Skip to content

Commit ddbf19a

Browse files
authored
Update dependencies (#11)
1 parent 95bc0c7 commit ddbf19a

File tree

8 files changed

+78
-61
lines changed

8 files changed

+78
-61
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -10,7 +10,7 @@ repos:
1010
- id: mixed-line-ending
1111
- id: check-case-conflict
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.5.0 # must match requirements-tests.txt
13+
rev: v0.7.3 # must match requirements-tests.txt
1414
hooks:
1515
- id: ruff
1616
- id: ruff-format

requirements-tests.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Tools
22
# -----
3-
ruff==0.5.0 # must match .pre-commit-config.yaml
3+
ruff==0.7.3 # must match .pre-commit-config.yaml
44
pytest>=8.0
55
rich-argparse>=1.5.2
6-
mypy==1.10.1
7-
pyright==1.1.369
6+
mypy==1.13.0
7+
pyright==1.1.388
88

99
# Runtime dependencies
1010
# --------------------
@@ -13,8 +13,8 @@ geopandas>=1.0.0
1313
# Transient dependencies
1414
# ----------------------
1515
# geopandas
16-
types-shapely>=2.0.0.20240613
17-
pandas-stubs>=2.2.2.240603
16+
types-shapely>=2.0.0.20240820
17+
pandas-stubs>=2.2.3.241009
1818
matplotlib>=3.8.0
1919
folium>=0.16.0
2020
rtree>=1.2.0

stubs/pandapower-stubs/toolbox.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ def get_element_index(net: pandapowerNet, element: str, name: str, exact_match:
252252
@overload
253253
def get_element_index(net: pandapowerNet, element: str, name: str, exact_match: bool = True) -> int | pd.Index[int]: ...
254254
@overload
255-
def get_element_indices( # type: ignore[overload-overlap]
255+
def get_element_indices(
256256
net: pandapowerNet, element: str | Iterable[str], name: str | Iterable[str], exact_match: Literal[True] = True
257257
) -> list[int]: ...
258258
@overload
259-
def get_element_indices( # type: ignore[overload-overlap]
259+
def get_element_indices(
260260
net: pandapowerNet, element: str | Iterable[str], name: str | Iterable[str], exact_match: Literal[False]
261261
) -> list[pd.Index[int]]: ...
262262
@overload

tests/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
from __future__ import annotations
22

33
from collections.abc import Iterable
4-
from types import UnionType
4+
from types import GenericAlias, UnionType
55
from typing import Any, TypeAlias, TypeVar, cast
66

77
import numpy as np
8+
from shapely.geometry.base import BaseMultipartGeometry, GeometrySequence
89

910
T = TypeVar("T")
1011
_ClassInfo: TypeAlias = type | UnionType | tuple["_ClassInfo", ...] # see isinstance
1112

13+
# Make stubs generic classes generic at runtime
14+
setattr(BaseMultipartGeometry, "__class_getitem__", classmethod(GenericAlias))
15+
setattr(GeometrySequence, "__class_getitem__", classmethod(GenericAlias))
16+
1217

1318
def check(obj: T, cls: _ClassInfo, dtype: _ClassInfo | None = None) -> T:
1419
__tracebackhide__ = True

tests/shapely/test_constructive.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636

3737
GEOMS: list[Geometry] = [P, MP, LS, MLS, LR, PO, MPO, GC]
3838

39+
PolygonizeFullCollections = tuple[
40+
GeometryCollection, GeometryCollection, GeometryCollection, GeometryCollection
41+
]
42+
PolygonizeFullArrays = tuple[
43+
NDArray[np.object_], NDArray[np.object_], NDArray[np.object_], NDArray[np.object_]
44+
]
45+
3946

4047
def test_boundary() -> None:
4148
check(assert_type(shapely.boundary(P), GeometryCollection), GeometryCollection)
@@ -310,30 +317,34 @@ def test_polygonize() -> None:
310317

311318

312319
def test_polygonize_full() -> None:
313-
FourCollections = tuple[
314-
GeometryCollection, GeometryCollection, GeometryCollection, GeometryCollection
315-
]
316-
FourArrays = tuple[
317-
NDArray[np.object_], NDArray[np.object_], NDArray[np.object_], NDArray[np.object_]
318-
]
319-
check(
320-
assert_type(shapely.polygonize_full([P, LS]), FourCollections),
320+
check(
321+
assert_type(shapely.polygonize_full([P, LS]), PolygonizeFullCollections),
321322
tuple,
322323
dtype=GeometryCollection,
323324
)
324325
check(
325-
assert_type(shapely.polygonize_full((LS, None)), FourCollections),
326+
assert_type(shapely.polygonize_full((LS, None)), PolygonizeFullCollections),
326327
tuple,
327328
dtype=GeometryCollection,
328329
)
329-
check(assert_type(shapely.polygonize_full([(LS, None)]), FourArrays), tuple, dtype=np.ndarray)
330330
check(
331-
assert_type(shapely.polygonize_full(np.array([P, LS])), FourCollections | FourArrays),
331+
assert_type(shapely.polygonize_full([(LS, None)]), PolygonizeFullArrays),
332+
tuple,
333+
dtype=np.ndarray,
334+
)
335+
check(
336+
assert_type(
337+
shapely.polygonize_full(np.array([P, LS])),
338+
PolygonizeFullCollections | PolygonizeFullArrays,
339+
),
332340
tuple,
333341
dtype=GeometryCollection,
334342
)
335343
check(
336-
assert_type(shapely.polygonize_full(np.array([[P, LS]])), FourCollections | FourArrays),
344+
assert_type(
345+
shapely.polygonize_full(np.array([[P, LS]])),
346+
PolygonizeFullCollections | PolygonizeFullArrays,
347+
),
337348
tuple,
338349
dtype=np.ndarray,
339350
)
@@ -449,7 +460,7 @@ def test_voronoi_polygons() -> None:
449460
check(assert_type(shapely.voronoi_polygons(None), None), NoneType)
450461
for geom in (LS, MLS, LR, PO, MPO, GC):
451462
check(
452-
assert_type(shapely.voronoi_polygons(geom), "GeometryCollection[Polygon]"),
463+
assert_type(shapely.voronoi_polygons(geom), GeometryCollection[Polygon]),
453464
GeometryCollection,
454465
)
455466
check(
@@ -467,7 +478,7 @@ def test_voronoi_polygons() -> None:
467478
check(
468479
assert_type(
469480
shapely.voronoi_polygons(geom, only_edges=bool(0.5)),
470-
"GeometryCollection[Polygon] | LineString | MultiLineString",
481+
GeometryCollection[Polygon] | LineString | MultiLineString,
471482
),
472483
LineString | MultiLineString,
473484
)

tests/shapely/test_geometry.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
def test_base_geometry_constructor() -> None:
4343
with pytest.warns(FutureWarning):
44-
check(assert_type(BaseGeometry(), GeometryCollection), GeometryCollection)
44+
check(assert_type(BaseGeometry(), GeometryCollection), GeometryCollection) # pyright: ignore[reportDeprecated]
4545

4646

4747
def test_geometry_operators() -> None:
@@ -237,20 +237,18 @@ def test_multipart_geometry() -> None:
237237
with pytest.raises(NotImplementedError):
238238
assert_never(MLS.coords)
239239

240-
check(assert_type(MP.geoms, "GeometrySequence[MultiPoint]"), GeometrySequence, Point)
241-
check(assert_type(MLS.geoms, "GeometrySequence[MultiLineString]"), GeometrySequence, LineString)
242-
check(assert_type(MPO.geoms, "GeometrySequence[MultiPolygon]"), GeometrySequence, Polygon)
240+
check(assert_type(MP.geoms, GeometrySequence[MultiPoint]), GeometrySequence, Point)
241+
check(assert_type(MLS.geoms, GeometrySequence[MultiLineString]), GeometrySequence, LineString)
242+
check(assert_type(MPO.geoms, GeometrySequence[MultiPolygon]), GeometrySequence, Polygon)
243243
check(
244-
assert_type(GC.geoms, "GeometrySequence[GeometryCollection]"),
245-
GeometrySequence,
246-
BaseGeometry,
244+
assert_type(GC.geoms, GeometrySequence[GeometryCollection]), GeometrySequence, BaseGeometry
247245
)
248246
check(assert_type(iter(MP.geoms), Iterator[Point]), Iterator, dtype=Point)
249247
check(assert_type(iter(MLS.geoms), Iterator[LineString]), Iterator, dtype=LineString)
250248
check(assert_type(iter(MPO.geoms), Iterator[Polygon]), Iterator, dtype=Polygon)
251249
check(assert_type(iter(GC.geoms), Iterator[BaseGeometry]), Iterator, dtype=BaseGeometry)
252250
polygons_collection = GeometryCollection(MPO)
253-
check(assert_type(polygons_collection, "GeometryCollection[Polygon]"), GeometryCollection)
251+
check(assert_type(polygons_collection, GeometryCollection[Polygon]), GeometryCollection)
254252
check(assert_type(iter(polygons_collection.geoms), Iterator[Polygon]), Iterator, dtype=Polygon)
255253
check(assert_type(MP.geoms[0], Point), Point)
256254
check(assert_type(MLS.geoms[0], LineString), LineString)

tests/shapely/test_linear.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
MP = MultiPoint([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
1818
MLS = MultiLineString([LS, PO.exterior])
1919

20+
LineMergeType = LineString | MultiLineString | GeometryCollection
21+
2022

2123
def test_line_interpolate_point() -> None:
2224
check(assert_type(shapely.line_interpolate_point(LS, 1.0), Point), Point)
@@ -86,13 +88,12 @@ def test_line_locate_point() -> None:
8688

8789

8890
def test_line_merge() -> None:
89-
expected_type = LineString | MultiLineString | GeometryCollection
90-
check(assert_type(shapely.line_merge(P), expected_type), GeometryCollection)
91-
check(assert_type(shapely.line_merge(LineString()), expected_type), GeometryCollection)
92-
check(assert_type(shapely.line_merge(MultiLineString()), expected_type), GeometryCollection)
93-
check(assert_type(shapely.line_merge(LS), expected_type), LineString)
94-
check(assert_type(shapely.line_merge(MLS), expected_type), MultiLineString)
95-
check(assert_type(shapely.line_merge(GeometryCollection(MLS)), expected_type), MultiLineString)
91+
check(assert_type(shapely.line_merge(P), LineMergeType), GeometryCollection)
92+
check(assert_type(shapely.line_merge(LineString()), LineMergeType), GeometryCollection)
93+
check(assert_type(shapely.line_merge(MultiLineString()), LineMergeType), GeometryCollection)
94+
check(assert_type(shapely.line_merge(LS), LineMergeType), LineString)
95+
check(assert_type(shapely.line_merge(MLS), LineMergeType), MultiLineString)
96+
check(assert_type(shapely.line_merge(GeometryCollection(MLS)), LineMergeType), MultiLineString)
9697
check(assert_type(shapely.line_merge(None), None), NoneType)
9798
check(
9899
assert_type(shapely.line_merge([LS, None]), NDArray[np.object_]),
@@ -104,12 +105,12 @@ def test_line_merge() -> None:
104105
np.ndarray,
105106
dtype=MultiLineString,
106107
)
107-
check(assert_type(shapely.line_merge(LS, directed=True), expected_type), LineString)
108+
check(assert_type(shapely.line_merge(LS, directed=True), LineMergeType), LineString)
108109

109110

110111
def test_shared_paths() -> None:
111112
check(
112-
assert_type(shapely.shared_paths(MLS, LS), "GeometryCollection[MultiLineString]"),
113+
assert_type(shapely.shared_paths(MLS, LS), GeometryCollection[MultiLineString]),
113114
GeometryCollection,
114115
)
115116
check(assert_type(shapely.shared_paths(MLS, None), None), NoneType)

tests/shapely/test_ops.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from types import NoneType
4+
from typing import TypeAlias
45

56
import pyproj
67
import pytest
@@ -16,10 +17,17 @@
1617
PO: Polygon = P.buffer(1)
1718
MP = MultiPoint([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
1819

20+
PolygonizeFull: TypeAlias = tuple[
21+
GeometryCollection[Polygon],
22+
GeometryCollection[LineString],
23+
GeometryCollection[LineString],
24+
GeometryCollection[Polygon],
25+
]
26+
1927

2028
def test_polygonize() -> None:
2129
check(
22-
assert_type(shapely.ops.polygonize(PO), "GeometrySequence[GeometryCollection[Polygon]]"),
30+
assert_type(shapely.ops.polygonize(PO), GeometrySequence[GeometryCollection[Polygon]]),
2331
GeometrySequence,
2432
dtype=Polygon,
2533
)
@@ -32,7 +40,7 @@ def test_polygonize() -> None:
3240
]
3341
check(
3442
assert_type(
35-
shapely.ops.polygonize(line_likes), "GeometrySequence[GeometryCollection[Polygon]]"
43+
shapely.ops.polygonize(line_likes), GeometrySequence[GeometryCollection[Polygon]]
3644
),
3745
GeometrySequence,
3846
dtype=Polygon,
@@ -44,12 +52,12 @@ def test_polygonize() -> None:
4452
]
4553
poly = shapely.ops.polygonize(lines)
4654
check(
47-
assert_type(poly, "GeometrySequence[GeometryCollection[Polygon]]"),
55+
assert_type(poly, GeometrySequence[GeometryCollection[Polygon]]),
4856
GeometrySequence,
4957
dtype=Polygon,
5058
)
5159
check(assert_type(poly[0], Polygon), Polygon)
52-
check(assert_type(poly[:], "GeometryCollection[Polygon]"), GeometryCollection)
60+
check(assert_type(poly[:], GeometryCollection[Polygon]), GeometryCollection)
5361
check(assert_type(list(poly), list[Polygon]), list, dtype=Polygon)
5462
check(assert_type(len(poly), int), int)
5563

@@ -64,22 +72,18 @@ def test_polygonize() -> None:
6472
None,
6573
)
6674
),
67-
"GeometrySequence[GeometryCollection[Polygon]]",
75+
GeometrySequence[GeometryCollection[Polygon]],
6876
),
6977
GeometrySequence,
7078
dtype=Polygon,
7179
)
7280

7381

7482
def test_polygonize_full() -> None:
75-
expected_type = tuple[
76-
"GeometryCollection[Polygon]",
77-
"GeometryCollection[LineString]",
78-
"GeometryCollection[LineString]",
79-
"GeometryCollection[Polygon]",
80-
]
8183
check(
82-
assert_type(shapely.ops.polygonize_full(PO), expected_type), tuple, dtype=GeometryCollection
84+
assert_type(shapely.ops.polygonize_full(PO), PolygonizeFull),
85+
tuple,
86+
dtype=GeometryCollection,
8387
)
8488
line_likes = [
8589
((0, 0), (1, 1)),
@@ -89,7 +93,7 @@ def test_polygonize_full() -> None:
8993
((1, 0), (0, 0)),
9094
]
9195
check(
92-
assert_type(shapely.ops.polygonize_full(line_likes), expected_type),
96+
assert_type(shapely.ops.polygonize_full(line_likes), PolygonizeFull),
9397
tuple,
9498
dtype=GeometryCollection,
9599
)
@@ -100,7 +104,7 @@ def test_polygonize_full() -> None:
100104
]
101105
poly = shapely.ops.polygonize_full(lines)
102106
assert len(poly) == 4
103-
check(assert_type(poly, expected_type), tuple, dtype=GeometryCollection)
107+
check(assert_type(poly, PolygonizeFull), tuple, dtype=GeometryCollection)
104108

105109
check(
106110
assert_type(
@@ -113,7 +117,7 @@ def test_polygonize_full() -> None:
113117
None,
114118
)
115119
),
116-
expected_type,
120+
PolygonizeFull,
117121
),
118122
tuple,
119123
dtype=GeometryCollection,
@@ -163,12 +167,10 @@ def test_triangulate() -> None:
163167

164168
def test_voronoi_diagram() -> None:
165169
regions = shapely.ops.voronoi_diagram(MP)
166-
check(assert_type(regions, "GeometryCollection[Polygon]"), GeometryCollection)
170+
check(assert_type(regions, GeometryCollection[Polygon]), GeometryCollection)
167171
check(list(regions.geoms), list, dtype=Polygon)
168172
edges = shapely.ops.voronoi_diagram(MP, edges=True)
169-
check(
170-
assert_type(edges, "GeometryCollection[LineString | MultiLineString]"), GeometryCollection
171-
)
173+
check(assert_type(edges, GeometryCollection[LineString | MultiLineString]), GeometryCollection)
172174
check(list(edges.geoms), list, dtype=MultiLineString)
173175

174176

@@ -212,7 +214,7 @@ def test_snap() -> None:
212214

213215
def test_shared_paths() -> None:
214216
shared = shapely.ops.shared_paths(LS, PO.exterior)
215-
check(assert_type(shared, "GeometryCollection[MultiLineString]"), GeometryCollection)
217+
check(assert_type(shared, GeometryCollection[MultiLineString]), GeometryCollection)
216218
with pytest.raises(Exception):
217219
shapely.ops.shared_paths(LS, PO) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
218220

0 commit comments

Comments
 (0)