Skip to content

Remove other pandas.core.index files from MyPy Blacklist #26315

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

Closed
wants to merge 2 commits into from
Closed
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
12 changes: 0 additions & 12 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,9 @@ ignore_errors=True
[mypy-pandas.core.api]
ignore_errors=True

[mypy-pandas.core.indexes.base]
ignore_errors=True

[mypy-pandas.core.indexes.datetimelike]
ignore_errors=True

[mypy-pandas.core.indexes.datetimes]
ignore_errors=True

[mypy-pandas.core.indexes.period]
ignore_errors=True

[mypy-pandas.core.indexes.timedeltas]
ignore_errors=True

[mypy-pandas.core.indexing]
ignore_errors=True

Expand Down
16 changes: 8 additions & 8 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
if fastpath:
return cls._simple_new(data, name)

from .range import RangeIndex
from pandas import RangeIndex
Copy link
Member

Choose a reason for hiding this comment

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

Can you convert these to absolute references rather than pulling from the top level?

Copy link
Contributor

Choose a reason for hiding this comment

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

this is ok, we do this all over the place

if isinstance(data, ABCPandasArray):
# ensure users don't accidentally put a PandasArray in an index.
data = data.to_numpy()
Expand All @@ -278,14 +278,14 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,

# categorical
elif is_categorical_dtype(data) or is_categorical_dtype(dtype):
from .category import CategoricalIndex
from pandas import CategoricalIndex
return CategoricalIndex(data, dtype=dtype, copy=copy, name=name,
**kwargs)

# interval
elif ((is_interval_dtype(data) or is_interval_dtype(dtype)) and
not is_object_dtype(dtype)):
from .interval import IntervalIndex
from pandas import IntervalIndex
closed = kwargs.get('closed', None)
return IntervalIndex(data, dtype=dtype, name=name, copy=copy,
closed=closed)
Expand Down Expand Up @@ -373,7 +373,7 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
pass

# Return an actual float index.
from .numeric import Float64Index
from pandas import Float64Index
return Float64Index(data, copy=copy, dtype=dtype,
name=name)

Expand Down Expand Up @@ -431,10 +431,10 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
return Index(subarr, copy=copy,
dtype=object, name=name)
elif inferred in ['floating', 'mixed-integer-float']:
from .numeric import Float64Index
from pandas import Float64Index
return Float64Index(subarr, copy=copy, name=name)
elif inferred == 'interval':
from .interval import IntervalIndex
from pandas import IntervalIndex
return IntervalIndex(subarr, name=name, copy=copy)
elif inferred == 'boolean':
# don't support boolean explicitly ATM
Expand Down Expand Up @@ -476,7 +476,7 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
if data and all(isinstance(e, tuple) for e in data):
# we must be all tuples, otherwise don't construct
# 10697
from .multi import MultiIndex
from pandas import MultiIndex
return MultiIndex.from_tuples(
data, names=name or kwargs.get('names'))
# other iterable of some kind
Expand Down Expand Up @@ -1556,7 +1556,7 @@ def droplevel(self, level=0):
result.name = new_names[0]
return result
else:
from .multi import MultiIndex
from pandas import MultiIndex
return MultiIndex(levels=new_levels, codes=new_codes,
names=new_names, verify_integrity=False)

Expand Down