Skip to content

Commit 1aebc99

Browse files
TYP: core.arrays.boolean (#31346)
1 parent d81e226 commit 1aebc99

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

pandas/core/arrays/boolean.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numbers
2-
from typing import TYPE_CHECKING, Any, List, Tuple, Type
2+
from typing import TYPE_CHECKING, Any, List, Tuple, Type, Union
33
import warnings
44

55
import numpy as np
@@ -30,7 +30,7 @@
3030
from .masked import BaseMaskedArray
3131

3232
if TYPE_CHECKING:
33-
from pandas._typing import Scalar
33+
import pyarrow # noqa: F401
3434

3535

3636
@register_extension_dtype
@@ -62,7 +62,7 @@ class BooleanDtype(ExtensionDtype):
6262
name = "boolean"
6363

6464
@property
65-
def na_value(self) -> "Scalar":
65+
def na_value(self) -> libmissing.NAType:
6666
"""
6767
BooleanDtype uses :attr:`pandas.NA` as the missing NA value.
6868
@@ -73,15 +73,22 @@ def na_value(self) -> "Scalar":
7373
return libmissing.NA
7474

7575
@property
76-
def type(self) -> Type:
76+
def type(self) -> Type[np.bool_]:
7777
return np.bool_
7878

7979
@property
8080
def kind(self) -> str:
8181
return "b"
8282

8383
@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+
"""
8592
return BooleanArray
8693

8794
def __repr__(self) -> str:
@@ -91,9 +98,13 @@ def __repr__(self) -> str:
9198
def _is_boolean(self) -> bool:
9299
return True
93100

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
97108

98109
if isinstance(array, pyarrow.Array):
99110
chunks = [array]
@@ -110,7 +121,9 @@ def __from_arrow__(self, array):
110121
return BooleanArray._concat_same_type(results)
111122

112123

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]:
114127
"""
115128
Coerce the input values array to numpy arrays with a mask.
116129

0 commit comments

Comments
 (0)