1
1
from _typeshed import Incomplete
2
- from typing import Literal
3
- from typing_extensions import TypeAlias
2
+ from collections .abc import Mapping
3
+ from typing import (
4
+ # pyarrow types returned as Any to avoid depending on pyarrow (40 MB) in stubs
5
+ Any as _PAArray ,
6
+ Any as _PAField ,
7
+ Any as _PATable ,
8
+ Literal ,
9
+ Protocol ,
10
+ type_check_only ,
11
+ )
12
+ from typing_extensions import CapsuleType , TypeAlias
4
13
5
14
import numpy as np
6
15
from numpy .typing import NDArray
7
16
8
17
from ..array import GeometryArray
9
18
from ..geodataframe import GeoDataFrame
10
19
11
- _PATable : TypeAlias = Incomplete
12
- _PAField : TypeAlias = Incomplete
13
- _PAArray : TypeAlias = Incomplete
14
-
15
20
# Literal for language server completions and str because runtime normalizes to lowercase
16
21
_GeomEncoding : TypeAlias = Literal ["WKB" , "geoarrow" ] | str # noqa: Y051
17
22
23
+ @type_check_only
24
+ class _PyarrowTableLike (Protocol ):
25
+ def __arrow_c_stream__ (self , requested_schema = None ) -> CapsuleType : ...
26
+
27
+ @type_check_only
28
+ class _PyarrowFieldLike (Protocol ):
29
+ def __arrow_c_schema__ (self ) -> CapsuleType : ...
30
+
31
+ @type_check_only
32
+ class _PyarrowArrayLike (Protocol ):
33
+ def __arrow_c_array__ (self ) -> tuple [CapsuleType , CapsuleType ]: ...
34
+
18
35
GEOARROW_ENCODINGS : list [str ]
19
36
20
37
class ArrowTable :
21
- def __init__ (self , pa_table : _PATable ) -> None : ...
22
- def __arrow_c_stream__ (self , requested_schema = None ): ...
38
+ def __init__ (self , pa_table : _PyarrowTableLike ) -> None : ...
39
+ def __arrow_c_stream__ (self , requested_schema = None ) -> CapsuleType : ...
23
40
24
41
class GeoArrowArray :
25
- def __init__ (self , pa_field : _PAField , pa_array : _PAArray ) -> None : ...
26
- def __arrow_c_array__ (self , requested_schema = None ) -> tuple [Incomplete , Incomplete ]: ...
42
+ def __init__ (self , pa_field : _PyarrowFieldLike , pa_array : _PyarrowArrayLike ) -> None : ...
43
+ def __arrow_c_array__ (self , requested_schema = None ) -> tuple [CapsuleType , CapsuleType ]: ...
27
44
28
45
def geopandas_to_arrow (
29
46
df : GeoDataFrame ,
@@ -43,6 +60,8 @@ def construct_geometry_array(
43
60
crs : str | None = None ,
44
61
interleaved : bool = True ,
45
62
) -> tuple [_PAField , _PAArray ]: ...
46
- def arrow_to_geopandas (table , geometry : str | None = None ) -> GeoDataFrame : ...
63
+ def arrow_to_geopandas (
64
+ table , geometry : str | None = None , to_pandas_kwargs : Mapping [str , Incomplete ] | None = None
65
+ ) -> GeoDataFrame : ...
47
66
def arrow_to_geometry_array (arr ) -> GeometryArray : ...
48
67
def construct_shapely_array (arr : _PAArray , extension_name : str ) -> NDArray [np .object_ ]: ...
0 commit comments