File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change 1
1
import operator
2
- from typing import Type
2
+ from typing import TYPE_CHECKING , Type , Union
3
3
4
4
import numpy as np
5
5
17
17
from pandas .core .construction import extract_array
18
18
from pandas .core .missing import isna
19
19
20
+ if TYPE_CHECKING :
21
+ import pyarrow # noqa: F401
22
+
20
23
21
24
@register_extension_dtype
22
25
class StringDtype (ExtensionDtype ):
@@ -53,19 +56,30 @@ class StringDtype(ExtensionDtype):
53
56
na_value = libmissing .NA
54
57
55
58
@property
56
- def type (self ) -> Type :
59
+ def type (self ) -> Type [ str ] :
57
60
return str
58
61
59
62
@classmethod
60
- def construct_array_type (cls ) -> "Type[StringArray]" :
63
+ def construct_array_type (cls ) -> Type ["StringArray" ]:
64
+ """
65
+ Return the array type associated with this dtype.
66
+
67
+ Returns
68
+ -------
69
+ type
70
+ """
61
71
return StringArray
62
72
63
73
def __repr__ (self ) -> str :
64
74
return "StringDtype"
65
75
66
- def __from_arrow__ (self , array ):
67
- """Construct StringArray from passed pyarrow Array/ChunkedArray"""
68
- import pyarrow
76
+ def __from_arrow__ (
77
+ self , array : Union ["pyarrow.Array" , "pyarrow.ChunkedArray" ]
78
+ ) -> "StringArray" :
79
+ """
80
+ Construct StringArray from pyarrow Array/ChunkedArray.
81
+ """
82
+ import pyarrow # noqa: F811
69
83
70
84
if isinstance (array , pyarrow .Array ):
71
85
chunks = [array ]
You can’t perform that action at this time.
0 commit comments