From 77db12eaf597e973729c8f34905011f40e48e25d Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Thu, 14 Nov 2019 00:32:54 +0200 Subject: [PATCH 1/3] Typing in pandas/core/dtypes/ --- pandas/core/dtypes/base.py | 4 ++-- pandas/core/dtypes/common.py | 6 +++--- pandas/core/dtypes/concat.py | 2 +- pandas/core/dtypes/missing.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pandas/core/dtypes/base.py b/pandas/core/dtypes/base.py index d9d3b0d45e218..c90f1cdeaabfd 100644 --- a/pandas/core/dtypes/base.py +++ b/pandas/core/dtypes/base.py @@ -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. @@ -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 diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 635bc5ce03680..dcc8a274492ee 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -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) @@ -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. @@ -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. diff --git a/pandas/core/dtypes/concat.py b/pandas/core/dtypes/concat.py index 768272e173c82..7b3e7d4f42121 100644 --- a/pandas/core/dtypes/concat.py +++ b/pandas/core/dtypes/concat.py @@ -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 diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index df89bd374f22e..34dc7dbc6cb1d 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -125,7 +125,7 @@ def isna(obj): isnull = isna -def _isna_new(obj): +def _isna_new(obj) -> bool: if is_scalar(obj): return libmissing.checknull(obj) @@ -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 ---------- @@ -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 From 5fc5318f15a2573cc2b8bda05584d2c57bd93fb3 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Thu, 14 Nov 2019 13:51:40 +0200 Subject: [PATCH 2/3] Fixes to @jbrockmendel review --- pandas/core/dtypes/missing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index 34dc7dbc6cb1d..aeba4eebc498e 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -125,7 +125,7 @@ def isna(obj): isnull = isna -def _isna_new(obj) -> bool: +def _isna_new(obj): if is_scalar(obj): return libmissing.checknull(obj) From 6f9941bde9f22159f9f4b11c66fc0020e73a2926 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <50263213+MomIsBestFriend@users.noreply.github.com> Date: Thu, 14 Nov 2019 15:25:24 +0200 Subject: [PATCH 3/3] change one thing Last tests failed because it couldn't reach an URL --- pandas/core/dtypes/dtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index a0712a0df237b..3d1388db371ca 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -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