11import sys
22from _typeshed import SupportsWrite as SupportsWrite
33from 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
66import numpy as np
7- from numpy .typing import NDArray
7+ import numpy .typing as npt
88
99from .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
5050class SupportsGeoInterface (Protocol ):
@@ -55,3 +55,21 @@ class SupportsGeoInterface(Protocol):
5555@type_check_only
5656class 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