Skip to content

Commit da65515

Browse files
[shapely] Type kwargs arguments (#15859)
1 parent d928f9e commit da65515

6 files changed

Lines changed: 521 additions & 331 deletions

File tree

stubs/shapely/shapely/_typing.pyi

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import sys
22
from _typeshed import SupportsWrite as SupportsWrite
33
from collections.abc import Sequence
4-
from typing import Any, Protocol, TypeAlias, TypeVar, type_check_only
4+
from typing import Any, Literal, Protocol, TypeAlias, TypedDict, TypeVar, type_check_only
55

66
import numpy as np
7-
from numpy.typing import NDArray
7+
import numpy.typing as npt
88

99
from .lib import Geometry
1010

@@ -44,7 +44,7 @@ OptGeoArrayLike: TypeAlias = ArrayLike[Geometry | None]
4444
# There is no way to pronounce "array of BaseGeometry" currently because of the restriction on
4545
# NDArray type variable to np.dtype and because np.object_ is not generic.
4646
# Note the use of `BaseGeometry` instead of `Geometry` as the alias is used in return types.
47-
GeoArray: TypeAlias = NDArray[np.object_]
47+
GeoArray: TypeAlias = npt.NDArray[np.object_]
4848

4949
@type_check_only
5050
class SupportsGeoInterface(Protocol):
@@ -55,3 +55,21 @@ class SupportsGeoInterface(Protocol):
5555
@type_check_only
5656
class SupportsRead(Protocol[_T_co]):
5757
def read(self) -> _T_co: ...
58+
59+
CastingKind: TypeAlias = Literal["no", "equiv", "safe", "same_kind", "unsafe"]
60+
OrderKind: TypeAlias = Literal["K", "A", "C", "F"]
61+
62+
@type_check_only
63+
class _UFuncKwargsBase(TypedDict, total=False):
64+
where: npt.ArrayLike
65+
casting: CastingKind
66+
order: OrderKind
67+
dtype: np.dtype[Any] | type[Any]
68+
subok: bool
69+
70+
@type_check_only
71+
class UFuncKwargs(_UFuncKwargsBase, total=False):
72+
out: npt.NDArray[Any] | tuple[npt.NDArray[Any], ...]
73+
74+
@type_check_only
75+
class UFuncKwargsNoOut(_UFuncKwargsBase, total=False): ...

0 commit comments

Comments
 (0)