Skip to content

Commit dd03c19

Browse files
TYP: pandas/core/dtypes/base.py (#31352)
1 parent 2154ad3 commit dd03c19

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pandas/core/dtypes/base.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
Extend pandas with custom array types.
33
"""
44

5-
from typing import Any, List, Optional, Tuple, Type
5+
from typing import TYPE_CHECKING, Any, List, Optional, Tuple, Type
66

77
import numpy as np
88

99
from pandas.errors import AbstractMethodError
1010

1111
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
1212

13+
if TYPE_CHECKING:
14+
from pandas.core.arrays import ExtensionArray # noqa: F401
15+
1316

1417
class ExtensionDtype:
1518
"""
@@ -29,7 +32,6 @@ class ExtensionDtype:
2932
3033
* type
3134
* name
32-
* construct_from_string
3335
3436
The following attributes influence the behavior of the dtype in
3537
pandas operations
@@ -74,7 +76,7 @@ class property**.
7476
class ExtensionDtype:
7577
7678
def __from_arrow__(
77-
self, array: pyarrow.Array/ChunkedArray
79+
self, array: Union[pyarrow.Array, pyarrow.ChunkedArray]
7880
) -> ExtensionArray:
7981
...
8082
@@ -122,11 +124,11 @@ def __eq__(self, other: Any) -> bool:
122124
def __hash__(self) -> int:
123125
return hash(tuple(getattr(self, attr) for attr in self._metadata))
124126

125-
def __ne__(self, other) -> bool:
127+
def __ne__(self, other: Any) -> bool:
126128
return not self.__eq__(other)
127129

128130
@property
129-
def na_value(self):
131+
def na_value(self) -> object:
130132
"""
131133
Default NA value to use for this type.
132134
@@ -184,7 +186,7 @@ def names(self) -> Optional[List[str]]:
184186
return None
185187

186188
@classmethod
187-
def construct_array_type(cls):
189+
def construct_array_type(cls) -> Type["ExtensionArray"]:
188190
"""
189191
Return the array type associated with this dtype.
190192
@@ -250,7 +252,7 @@ def construct_from_string(cls, string: str):
250252
return cls()
251253

252254
@classmethod
253-
def is_dtype(cls, dtype) -> bool:
255+
def is_dtype(cls, dtype: object) -> bool:
254256
"""
255257
Check if we match 'dtype'.
256258
@@ -261,7 +263,7 @@ def is_dtype(cls, dtype) -> bool:
261263
262264
Returns
263265
-------
264-
is_dtype : bool
266+
bool
265267
266268
Notes
267269
-----

0 commit comments

Comments
 (0)