Skip to content

MyPy cleanup and absolute imports in pandas.core.dtypes.common #21008

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 5 commits into from
Jun 23, 2018
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
2 changes: 1 addition & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,14 +788,14 @@ 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
used for interacting with our indexers.

- categorical -> codes
"""
# type: () -> np.ndarray
if is_extension_array_dtype(self):
return self.values._ndarray_values
return self.values
Expand Down
24 changes: 13 additions & 11 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are quite some other places where we use relative imports as well (but of course not consistently ..), but so why change those and not others?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn’t the relative import that mypy was complaining about as much as the starred import. I just figured I’d convert the relative to absolute while I was touching the module

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 ( # 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)


_POSSIBLY_CAST_DTYPES = set([np.dtype(t).name
Expand Down