Skip to content

Commit a71d67b

Browse files
jbrockmendelproost
authored andcommitted
TYP: annotate _data (pandas-dev#29580)
1 parent f7bed5d commit a71d67b

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

pandas/core/indexes/base.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _outer_indexer(self, left, right):
230230
return libjoin.outer_join_indexer(left, right)
231231

232232
_typ = "index"
233-
_data = None
233+
_data: Union[ExtensionArray, np.ndarray]
234234
_id = None
235235
name = None
236236
_comparables = ["name"]
@@ -653,8 +653,6 @@ def __len__(self) -> int:
653653
"""
654654
Return the length of the Index.
655655
"""
656-
# Assertion needed for mypy, see GH#29475
657-
assert self._data is not None
658656
return len(self._data)
659657

660658
def __array__(self, dtype=None):

pandas/core/indexes/datetimelike.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from pandas.core import algorithms, ops
2929
from pandas.core.accessor import PandasDelegate
30-
from pandas.core.arrays import ExtensionOpsMixin
30+
from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin
3131
from pandas.core.arrays.datetimelike import (
3232
DatetimeLikeArrayMixin,
3333
_ensure_datetimelike_to_i8,
@@ -78,7 +78,7 @@ class DatetimeIndexOpsMixin(ExtensionOpsMixin):
7878
common ops mixin to support a unified interface datetimelike Index
7979
"""
8080

81-
_data = None
81+
_data: ExtensionArray
8282

8383
# DatetimeLikeArrayMixin assumes subclasses are mutable, so these are
8484
# properties there. They can be made into cache_readonly for Index
@@ -836,7 +836,7 @@ class DatetimelikeDelegateMixin(PandasDelegate):
836836
# raw_properties : dispatch properties that shouldn't be boxed in an Index
837837
_raw_properties = set() # type: Set[str]
838838
name = None
839-
_data = None
839+
_data: ExtensionArray
840840

841841
@property
842842
def _delegate_class(self):

pandas/core/indexes/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin):
174174
_is_numeric_dtype = False
175175
_infer_as_myclass = True
176176

177-
_data = None
177+
_data: PeriodArray
178178

179179
_engine_type = libindex.PeriodEngine
180180
_supports_partial_string_indexing = True

0 commit comments

Comments
 (0)