Skip to content

Commit

Permalink
TYP: pandas/core/dtypes/base.py (pandas-dev#31352)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins authored Feb 12, 2020
1 parent 2154ad3 commit dd03c19
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
Extend pandas with custom array types.
"""

from typing import Any, List, Optional, Tuple, Type
from typing import TYPE_CHECKING, Any, List, Optional, Tuple, Type

import numpy as np

from pandas.errors import AbstractMethodError

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

if TYPE_CHECKING:
from pandas.core.arrays import ExtensionArray # noqa: F401


class ExtensionDtype:
"""
Expand All @@ -29,7 +32,6 @@ class ExtensionDtype:
* type
* name
* construct_from_string
The following attributes influence the behavior of the dtype in
pandas operations
Expand Down Expand Up @@ -74,7 +76,7 @@ class property**.
class ExtensionDtype:
def __from_arrow__(
self, array: pyarrow.Array/ChunkedArray
self, array: Union[pyarrow.Array, pyarrow.ChunkedArray]
) -> ExtensionArray:
...
Expand Down Expand Up @@ -122,11 +124,11 @@ def __eq__(self, other: Any) -> bool:
def __hash__(self) -> int:
return hash(tuple(getattr(self, attr) for attr in self._metadata))

def __ne__(self, other) -> bool:
def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

@property
def na_value(self):
def na_value(self) -> object:
"""
Default NA value to use for this type.
Expand Down Expand Up @@ -184,7 +186,7 @@ def names(self) -> Optional[List[str]]:
return None

@classmethod
def construct_array_type(cls):
def construct_array_type(cls) -> Type["ExtensionArray"]:
"""
Return the array type associated with this dtype.
Expand Down Expand Up @@ -250,7 +252,7 @@ def construct_from_string(cls, string: str):
return cls()

@classmethod
def is_dtype(cls, dtype) -> bool:
def is_dtype(cls, dtype: object) -> bool:
"""
Check if we match 'dtype'.
Expand All @@ -261,7 +263,7 @@ def is_dtype(cls, dtype) -> bool:
Returns
-------
is_dtype : bool
bool
Notes
-----
Expand Down

0 comments on commit dd03c19

Please sign in to comment.