Skip to content

Commit 43fb342

Browse files
check_untyped_defs pandas.core.indexes.datetimes
1 parent 99ce0e7 commit 43fb342

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pandas/core/indexes/datetimes.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import datetime, time, timedelta
22
import operator
3+
from typing import Type, cast
34
import warnings
45

56
import numpy as np
@@ -228,7 +229,9 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin):
228229
_join_precedence = 10
229230

230231
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)
232235

233236
_inner_indexer = _join_i8_wrapper(libjoin.inner_join_indexer_int64)
234237
_outer_indexer = _join_i8_wrapper(libjoin.outer_join_indexer_int64)
@@ -513,6 +516,7 @@ def _union(self, other, sort):
513516
if isinstance(result, DatetimeIndex):
514517
# TODO: we shouldn't be setting attributes like this;
515518
# in all the tests this equality already holds
519+
assert result._data is not None
516520
result._data._dtype = this.dtype
517521
if result.freq is None and (
518522
this.freq is not None or other.freq is not None
@@ -547,6 +551,7 @@ def union_many(self, others):
547551
if isinstance(this, DatetimeIndex):
548552
# TODO: we shouldn't be setting attributes like this;
549553
# in all the tests this equality already holds
554+
assert this._data is not None
550555
this._data._dtype = dtype
551556
return this
552557

@@ -803,7 +808,8 @@ def _maybe_utc_convert(self, other):
803808

804809
if not timezones.tz_compare(self.tz, other.tz):
805810
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]
807813
return this, other
808814

809815
def _wrap_joined_index(self, joined, other):
@@ -1156,7 +1162,8 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
11561162
end_casted = self._maybe_cast_slice_bound(end, "right", kind)
11571163
mask = (self <= end_casted) & mask
11581164

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]
11601167
if len(indexer) == len(self):
11611168
return slice(None)
11621169
else:

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ check_untyped_defs=False
182182
[mypy-pandas.core.frame]
183183
check_untyped_defs=False
184184

185-
[mypy-pandas.core.indexes.datetimes]
186-
check_untyped_defs=False
187-
188185
[mypy-pandas.core.indexes.timedeltas]
189186
check_untyped_defs=False
190187

0 commit comments

Comments
 (0)