1
1
import numbers
2
- from typing import TYPE_CHECKING , Any , List , Tuple , Type
2
+ from typing import TYPE_CHECKING , Any , List , Tuple , Type , Union
3
3
import warnings
4
4
5
5
import numpy as np
30
30
from .masked import BaseMaskedArray
31
31
32
32
if TYPE_CHECKING :
33
- from pandas . _typing import Scalar
33
+ import pyarrow # noqa: F401
34
34
35
35
36
36
@register_extension_dtype
@@ -62,7 +62,7 @@ class BooleanDtype(ExtensionDtype):
62
62
name = "boolean"
63
63
64
64
@property
65
- def na_value (self ) -> "Scalar" :
65
+ def na_value (self ) -> libmissing . NAType :
66
66
"""
67
67
BooleanDtype uses :attr:`pandas.NA` as the missing NA value.
68
68
@@ -73,15 +73,22 @@ def na_value(self) -> "Scalar":
73
73
return libmissing .NA
74
74
75
75
@property
76
- def type (self ) -> Type :
76
+ def type (self ) -> Type [ np . bool_ ] :
77
77
return np .bool_
78
78
79
79
@property
80
80
def kind (self ) -> str :
81
81
return "b"
82
82
83
83
@classmethod
84
- def construct_array_type (cls ) -> "Type[BooleanArray]" :
84
+ def construct_array_type (cls ) -> Type ["BooleanArray" ]:
85
+ """
86
+ Return the array type associated with this dtype.
87
+
88
+ Returns
89
+ -------
90
+ type
91
+ """
85
92
return BooleanArray
86
93
87
94
def __repr__ (self ) -> str :
@@ -91,9 +98,13 @@ def __repr__(self) -> str:
91
98
def _is_boolean (self ) -> bool :
92
99
return True
93
100
94
- def __from_arrow__ (self , array ):
95
- """Construct BooleanArray from passed pyarrow Array/ChunkedArray"""
96
- import pyarrow
101
+ def __from_arrow__ (
102
+ self , array : Union ["pyarrow.Array" , "pyarrow.ChunkedArray" ]
103
+ ) -> "BooleanArray" :
104
+ """
105
+ Construct BooleanArray from pyarrow Array/ChunkedArray.
106
+ """
107
+ import pyarrow # noqa: F811
97
108
98
109
if isinstance (array , pyarrow .Array ):
99
110
chunks = [array ]
@@ -110,7 +121,9 @@ def __from_arrow__(self, array):
110
121
return BooleanArray ._concat_same_type (results )
111
122
112
123
113
- def coerce_to_array (values , mask = None , copy : bool = False ):
124
+ def coerce_to_array (
125
+ values , mask = None , copy : bool = False
126
+ ) -> Tuple [np .ndarray , np .ndarray ]:
114
127
"""
115
128
Coerce the input values array to numpy arrays with a mask.
116
129
0 commit comments