From 31ed2cdabbc4b8322188ed8038db8c594ce81d75 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 10 May 2018 19:34:02 -0700 Subject: [PATCH 1/2] MyPy cleanup and abs imports in dtypes.common --- pandas/core/arrays/base.py | 2 +- pandas/core/base.py | 2 +- pandas/core/dtypes/common.py | 24 +++++++++++++----------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 1922801c30719..13039f35049c7 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -195,13 +195,13 @@ def __setitem__(self, key, value): ) def __len__(self): + # type: () -> int """Length of this array Returns ------- length : int """ - # type: () -> int raise AbstractMethodError(self) def __iter__(self): diff --git a/pandas/core/base.py b/pandas/core/base.py index 5022beabef76b..009f46bd984fe 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -788,6 +788,7 @@ def base(self): @property def _ndarray_values(self): + # type: () -> np.ndarray """The data as an ndarray, possibly losing information. The expectation is that this is cheap to compute, and is primarily @@ -795,7 +796,6 @@ def _ndarray_values(self): - categorical -> codes """ - # type: () -> np.ndarray if is_extension_array_dtype(self): return self.values._ndarray_values return self.values diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index c45838e6040a9..a6ed8ea99d135 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -5,17 +5,19 @@ PY3, PY36) from pandas._libs import algos, lib from pandas._libs.tslibs import conversion -from .dtypes import (CategoricalDtype, CategoricalDtypeType, - DatetimeTZDtype, DatetimeTZDtypeType, - PeriodDtype, PeriodDtypeType, - IntervalDtype, IntervalDtypeType, - ExtensionDtype, PandasExtensionDtype) -from .generic import (ABCCategorical, ABCPeriodIndex, - ABCDatetimeIndex, ABCSeries, - ABCSparseArray, ABCSparseSeries, ABCCategoricalIndex, - ABCIndexClass, ABCDateOffset) -from .inference import is_string_like, is_list_like -from .inference import * # noqa +from pandas.core.dtypes.dtypes import ( + CategoricalDtype, CategoricalDtypeType, DatetimeTZDtype, + DatetimeTZDtypeType, PeriodDtype, PeriodDtypeType, IntervalDtype, + IntervalDtypeType, ExtensionDtype, PandasExtensionDtype) +from pandas.core.dtypes.generic import ( + ABCCategorical, ABCPeriodIndex, ABCDatetimeIndex, ABCSeries, + ABCSparseArray, ABCSparseSeries, ABCCategoricalIndex, ABCIndexClass, + ABCDateOffset) +from pandas.core.dtypes.inference import ( + is_bool, is_integer, is_number, is_hashable, is_iterator, is_float, + is_dict_like, is_scalar, is_string_like, is_list_like, is_number, + is_file_like, is_re, is_re_compilable, is_sequence, is_nested_list_like, + is_named_tuple, is_array_like, is_decimal, is_complex, is_interval) _POSSIBLY_CAST_DTYPES = set([np.dtype(t).name From 86d2af86a541158979bbfa3bfb3eb75ccc1951b9 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Fri, 11 May 2018 14:23:14 -0400 Subject: [PATCH 2/2] LINT fixup --- pandas/core/dtypes/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index a6ed8ea99d135..05f82c67ddb8b 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -13,8 +13,8 @@ ABCCategorical, ABCPeriodIndex, ABCDatetimeIndex, ABCSeries, ABCSparseArray, ABCSparseSeries, ABCCategoricalIndex, ABCIndexClass, ABCDateOffset) -from pandas.core.dtypes.inference import ( - is_bool, is_integer, is_number, is_hashable, is_iterator, is_float, +from pandas.core.dtypes.inference import ( # noqa:F401 + is_bool, is_integer, is_hashable, is_iterator, is_float, is_dict_like, is_scalar, is_string_like, is_list_like, is_number, is_file_like, is_re, is_re_compilable, is_sequence, is_nested_list_like, is_named_tuple, is_array_like, is_decimal, is_complex, is_interval)