Skip to content

Commit 6d9b702

Browse files
gwromejreback
authored andcommitted
pandas-dev#25942 Added ArrayLike and Dtype to pandas._typing (pandas-dev#25943)
1 parent 6bb9ab8 commit 6d9b702

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pandas/_typing.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
from pathlib import Path
22
from typing import IO, AnyStr, Union
33

4+
import numpy as np
5+
6+
from pandas.core.dtypes.dtypes import ExtensionDtype
7+
from pandas.core.dtypes.generic import ABCExtensionArray
8+
9+
ArrayLike = Union[ABCExtensionArray, np.ndarray]
10+
Dtype = Union[str, np.dtype, ExtensionDtype]
411
FilePathOrBuffer = Union[str, Path, IO[AnyStr]]

pandas/core/arrays/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
ABCExtensionArray, ABCIndexClass, ABCSeries)
2222
from pandas.core.dtypes.missing import isna
2323

24+
from pandas._typing import ArrayLike
2425
from pandas.core import ops
2526

2627
_not_implemented_message = "{} does not implement {}."
@@ -338,7 +339,7 @@ def astype(self, dtype, copy=True):
338339
"""
339340
return np.array(self, dtype=dtype, copy=copy)
340341

341-
def isna(self) -> Union[ABCExtensionArray, np.ndarray]:
342+
def isna(self) -> ArrayLike:
342343
"""
343344
A 1-D array indicating if each value is missing.
344345

pandas/core/arrays/sparse.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numbers
66
import operator
77
import re
8-
from typing import Any, Callable, Type, Union
8+
from typing import Any, Callable
99
import warnings
1010

1111
import numpy as np
@@ -31,6 +31,7 @@
3131
ABCIndexClass, ABCSeries, ABCSparseArray, ABCSparseSeries)
3232
from pandas.core.dtypes.missing import isna, na_value_for_dtype, notna
3333

34+
from pandas._typing import Dtype
3435
from pandas.core.accessor import PandasDelegate, delegate_names
3536
import pandas.core.algorithms as algos
3637
from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin
@@ -80,7 +81,7 @@ class SparseDtype(ExtensionDtype):
8081

8182
def __init__(
8283
self,
83-
dtype: Union[str, np.dtype, ExtensionDtype, Type] = np.float64,
84+
dtype: Dtype = np.float64,
8485
fill_value: Any = None
8586
) -> None:
8687
from pandas.core.dtypes.missing import na_value_for_dtype

0 commit comments

Comments
 (0)