Skip to content

CLN:Typing in pandas/core/dtypes/ #29606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __from_arrow__(
def __str__(self) -> str:
return self.name

def __eq__(self, other):
def __eq__(self, other) -> bool:
"""
Check whether 'other' is equal to self.

Expand Down Expand Up @@ -119,7 +119,7 @@ def __eq__(self, other):
def __hash__(self) -> int:
return hash(tuple(getattr(self, attr) for attr in self._metadata))

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

@property
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def is_string_dtype(arr_or_dtype) -> bool:
"""

# TODO: gh-15585: consider making the checks stricter.
def condition(dtype):
def condition(dtype) -> bool:
return dtype.kind in ("O", "S", "U") and not is_period_dtype(dtype)

return _is_dtype(arr_or_dtype, condition)
Expand Down Expand Up @@ -1496,7 +1496,7 @@ def is_bool_dtype(arr_or_dtype) -> bool:
return issubclass(dtype.type, np.bool_)


def is_extension_type(arr):
def is_extension_type(arr) -> bool:
"""
Check whether an array-like is of a pandas extension class instance.

Expand Down Expand Up @@ -1561,7 +1561,7 @@ def is_extension_type(arr):
return False


def is_extension_array_dtype(arr_or_dtype):
def is_extension_array_dtype(arr_or_dtype) -> bool:
"""
Check if an object is a pandas extension array type.

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def concat_compat(to_concat, axis: int = 0):

# filter empty arrays
# 1-d dtypes always are included here
def is_nonempty(x):
def is_nonempty(x) -> bool:
if x.ndim <= axis:
return True
return x.shape[axis] > 0
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def register_extension_dtype(cls: Type[ExtensionDtype]) -> Type[ExtensionDtype]:

class Registry:
"""
Registry for dtype inference
Registry for dtype inference.

The registry allows one to map a string repr of a extension
dtype to an extension dtype. The string alias can be used in several
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def notna(obj):
notnull = notna


def _isna_compat(arr, fill_value=np.nan):
def _isna_compat(arr, fill_value=np.nan) -> bool:
"""
Parameters
----------
Expand All @@ -392,7 +392,7 @@ def _isna_compat(arr, fill_value=np.nan):
return True


def array_equivalent(left, right, strict_nan: bool = False):
def array_equivalent(left, right, strict_nan: bool = False) -> bool:
"""
True if two arrays, left and right, have equal non-NaN elements, and NaNs
in corresponding locations. False otherwise. It is assumed that left and
Expand Down