Skip to content

Commit

Permalink
pandas-dev#25942 Added ArrayLike and Dtype to pandas._typing
Browse files Browse the repository at this point in the history
  • Loading branch information
gwrome committed Mar 31, 2019
1 parent de3a85c commit 0761dab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion pandas/_typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from pathlib import Path
from typing import IO, AnyStr, Union
from typing import IO, AnyStr, Type, Union

import numpy as np

from pandas.core.dtypes.dtypes import ExtensionDtype
from pandas.core.dtypes.generic import ABCExtensionArray

ArrayLike = Union[ABCExtensionArray, np.ndarray]
Dtype = Union[str, np.dtype, ExtensionDtype, Type]
FilePathOrBuffer = Union[str, Path, IO[AnyStr]]
3 changes: 2 additions & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ABCExtensionArray, ABCIndexClass, ABCSeries)
from pandas.core.dtypes.missing import isna

from pandas._typing import ArrayLike
from pandas.core import ops

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

def isna(self) -> Union[ABCExtensionArray, np.ndarray]:
def isna(self) -> ArrayLike:
"""
A 1-D array indicating if each value is missing.
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/arrays/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numbers
import operator
import re
from typing import Any, Callable, Type, Union
from typing import Any, Callable
import warnings

import numpy as np
Expand All @@ -30,6 +30,7 @@
ABCIndexClass, ABCSeries, ABCSparseArray, ABCSparseSeries)
from pandas.core.dtypes.missing import isna, na_value_for_dtype, notna

from pandas._typing import Dtype
from pandas.core.accessor import PandasDelegate, delegate_names
import pandas.core.algorithms as algos
from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin
Expand Down Expand Up @@ -79,7 +80,7 @@ class SparseDtype(ExtensionDtype):

def __init__(
self,
dtype: Union[str, np.dtype, ExtensionDtype, Type] = np.float64,
dtype: Dtype = np.float64,
fill_value: Any = None
) -> None:
from pandas.core.dtypes.missing import na_value_for_dtype
Expand Down

0 comments on commit 0761dab

Please sign in to comment.