|
1 | 1 | from datetime import datetime, time, timedelta
|
2 | 2 | import operator
|
| 3 | +from typing import Type, cast |
3 | 4 | import warnings
|
4 | 5 |
|
5 | 6 | import numpy as np
|
@@ -228,7 +229,9 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin):
|
228 | 229 | _join_precedence = 10
|
229 | 230 |
|
230 | 231 | def _join_i8_wrapper(joinf, **kwargs):
|
231 |
| - return DatetimeIndexOpsMixin._join_i8_wrapper(joinf, dtype="M8[ns]", **kwargs) |
| 232 | + return cast( |
| 233 | + Type[DatetimeIndexOpsMixin], DatetimeIndexOpsMixin |
| 234 | + )._join_i8_wrapper(joinf, dtype="M8[ns]", **kwargs) |
232 | 235 |
|
233 | 236 | _inner_indexer = _join_i8_wrapper(libjoin.inner_join_indexer_int64)
|
234 | 237 | _outer_indexer = _join_i8_wrapper(libjoin.outer_join_indexer_int64)
|
@@ -513,6 +516,7 @@ def _union(self, other, sort):
|
513 | 516 | if isinstance(result, DatetimeIndex):
|
514 | 517 | # TODO: we shouldn't be setting attributes like this;
|
515 | 518 | # in all the tests this equality already holds
|
| 519 | + assert result._data is not None |
516 | 520 | result._data._dtype = this.dtype
|
517 | 521 | if result.freq is None and (
|
518 | 522 | this.freq is not None or other.freq is not None
|
@@ -547,6 +551,7 @@ def union_many(self, others):
|
547 | 551 | if isinstance(this, DatetimeIndex):
|
548 | 552 | # TODO: we shouldn't be setting attributes like this;
|
549 | 553 | # in all the tests this equality already holds
|
| 554 | + assert this._data is not None |
550 | 555 | this._data._dtype = dtype
|
551 | 556 | return this
|
552 | 557 |
|
@@ -803,7 +808,8 @@ def _maybe_utc_convert(self, other):
|
803 | 808 |
|
804 | 809 | if not timezones.tz_compare(self.tz, other.tz):
|
805 | 810 | this = self.tz_convert("UTC")
|
806 |
| - other = other.tz_convert("UTC") |
| 811 | + # error: "DatetimeIndex" has no attribute "tz_convert" [attr-defined] |
| 812 | + other = other.tz_convert("UTC") # type: ignore[attr-defined] |
807 | 813 | return this, other
|
808 | 814 |
|
809 | 815 | def _wrap_joined_index(self, joined, other):
|
@@ -1156,7 +1162,8 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
|
1156 | 1162 | end_casted = self._maybe_cast_slice_bound(end, "right", kind)
|
1157 | 1163 | mask = (self <= end_casted) & mask
|
1158 | 1164 |
|
1159 |
| - indexer = mask.nonzero()[0][::step] |
| 1165 | + # error: "bool" has no attribute "nonzero" [attr-defined] |
| 1166 | + indexer = mask.nonzero()[0][::step] # type: ignore[attr-defined] |
1160 | 1167 | if len(indexer) == len(self):
|
1161 | 1168 | return slice(None)
|
1162 | 1169 | else:
|
|
0 commit comments