@@ -454,7 +454,7 @@ def astype(self, dtype, copy: bool = True):
454
454
455
455
if dtype == object :
456
456
if self .dtype .kind == "M" :
457
- self = cast ("DatetimeArray" , self ) # noqa: PLW0642
457
+ self = cast ("DatetimeArray" , self )
458
458
# *much* faster than self._box_values
459
459
# for e.g. test_get_loc_tuple_monotonic_above_size_cutoff
460
460
i8data = self .asi8
@@ -776,7 +776,7 @@ def isin(self, values: ArrayLike) -> npt.NDArray[np.bool_]:
776
776
return np .zeros (self .shape , dtype = bool )
777
777
778
778
if self .dtype .kind in "mM" :
779
- self = cast ("DatetimeArray | TimedeltaArray" , self ) # noqa: PLW0642
779
+ self = cast ("DatetimeArray | TimedeltaArray" , self )
780
780
# error: "DatetimeLikeArrayMixin" has no attribute "as_unit"
781
781
values = values .as_unit (self .unit ) # type: ignore[attr-defined]
782
782
@@ -977,7 +977,7 @@ def _cmp_method(self, other, op):
977
977
return result
978
978
979
979
if not isinstance (self .dtype , PeriodDtype ):
980
- self = cast (TimelikeOps , self ) # noqa: PLW0642
980
+ self = cast (TimelikeOps , self )
981
981
if self ._creso != other ._creso :
982
982
if not isinstance (other , type (self )):
983
983
# i.e. Timedelta/Timestamp, cast to ndarray and let
@@ -1063,7 +1063,7 @@ def _add_datetimelike_scalar(self, other) -> DatetimeArray:
1063
1063
f"cannot add { type (self ).__name__ } and { type (other ).__name__ } "
1064
1064
)
1065
1065
1066
- self = cast ("TimedeltaArray" , self ) # noqa: PLW0642
1066
+ self = cast ("TimedeltaArray" , self )
1067
1067
1068
1068
from pandas .core .arrays import DatetimeArray
1069
1069
from pandas .core .arrays .datetimes import tz_to_dtype
@@ -1078,8 +1078,8 @@ def _add_datetimelike_scalar(self, other) -> DatetimeArray:
1078
1078
return DatetimeArray ._simple_new (result , dtype = result .dtype )
1079
1079
1080
1080
other = Timestamp (other )
1081
- self , other = self ._ensure_matching_resos (other ) # noqa: PLW0642
1082
- self = cast ("TimedeltaArray" , self ) # noqa: PLW0642
1081
+ self , other = self ._ensure_matching_resos (other )
1082
+ self = cast ("TimedeltaArray" , self )
1083
1083
1084
1084
other_i8 , o_mask = self ._get_i8_values_and_mask (other )
1085
1085
result = add_overflowsafe (self .asi8 , np .asarray (other_i8 , dtype = "i8" ))
@@ -1107,7 +1107,7 @@ def _sub_datetimelike_scalar(
1107
1107
if self .dtype .kind != "M" :
1108
1108
raise TypeError (f"cannot subtract a datelike from a { type (self ).__name__ } " )
1109
1109
1110
- self = cast ("DatetimeArray" , self ) # noqa: PLW0642
1110
+ self = cast ("DatetimeArray" , self )
1111
1111
# subtract a datetime from myself, yielding a ndarray[timedelta64[ns]]
1112
1112
1113
1113
if isna (other ):
@@ -1116,7 +1116,7 @@ def _sub_datetimelike_scalar(
1116
1116
1117
1117
ts = Timestamp (other )
1118
1118
1119
- self , ts = self ._ensure_matching_resos (ts ) # noqa: PLW0642
1119
+ self , ts = self ._ensure_matching_resos (ts )
1120
1120
return self ._sub_datetimelike (ts )
1121
1121
1122
1122
@final
@@ -1127,14 +1127,14 @@ def _sub_datetime_arraylike(self, other: DatetimeArray) -> TimedeltaArray:
1127
1127
if len (self ) != len (other ):
1128
1128
raise ValueError ("cannot add indices of unequal length" )
1129
1129
1130
- self = cast ("DatetimeArray" , self ) # noqa: PLW0642
1130
+ self = cast ("DatetimeArray" , self )
1131
1131
1132
- self , other = self ._ensure_matching_resos (other ) # noqa: PLW0642
1132
+ self , other = self ._ensure_matching_resos (other )
1133
1133
return self ._sub_datetimelike (other )
1134
1134
1135
1135
@final
1136
1136
def _sub_datetimelike (self , other : Timestamp | DatetimeArray ) -> TimedeltaArray :
1137
- self = cast ("DatetimeArray" , self ) # noqa: PLW0642
1137
+ self = cast ("DatetimeArray" , self )
1138
1138
1139
1139
from pandas .core .arrays import TimedeltaArray
1140
1140
@@ -1183,9 +1183,9 @@ def _add_timedeltalike_scalar(self, other):
1183
1183
return type (self )._simple_new (new_values , dtype = self .dtype )
1184
1184
1185
1185
# PeriodArray overrides, so we only get here with DTA/TDA
1186
- self = cast ("DatetimeArray | TimedeltaArray" , self ) # noqa: PLW0642
1186
+ self = cast ("DatetimeArray | TimedeltaArray" , self )
1187
1187
other = Timedelta (other )
1188
- self , other = self ._ensure_matching_resos (other ) # noqa: PLW0642
1188
+ self , other = self ._ensure_matching_resos (other )
1189
1189
return self ._add_timedeltalike (other )
1190
1190
1191
1191
def _add_timedelta_arraylike (self , other : TimedeltaArray ) -> Self :
@@ -1201,7 +1201,7 @@ def _add_timedelta_arraylike(self, other: TimedeltaArray) -> Self:
1201
1201
if len (self ) != len (other ):
1202
1202
raise ValueError ("cannot add indices of unequal length" )
1203
1203
1204
- self , other = cast ( # noqa: PLW0642
1204
+ self , other = cast (
1205
1205
"DatetimeArray | TimedeltaArray" , self
1206
1206
)._ensure_matching_resos (other )
1207
1207
return self ._add_timedeltalike (other )
@@ -1258,7 +1258,7 @@ def _sub_nat(self) -> np.ndarray:
1258
1258
result .fill (iNaT )
1259
1259
if self .dtype .kind in "mM" :
1260
1260
# We can retain unit in dtype
1261
- self = cast ("DatetimeArray| TimedeltaArray" , self ) # noqa: PLW0642
1261
+ self = cast ("DatetimeArray| TimedeltaArray" , self )
1262
1262
return result .view (f"timedelta64[{ self .unit } ]" )
1263
1263
else :
1264
1264
return result .view ("timedelta64[ns]" )
@@ -1272,7 +1272,7 @@ def _sub_periodlike(self, other: Period | PeriodArray) -> npt.NDArray[np.object_
1272
1272
f"cannot subtract { type (other ).__name__ } from { type (self ).__name__ } "
1273
1273
)
1274
1274
1275
- self = cast ("PeriodArray" , self ) # noqa: PLW0642
1275
+ self = cast ("PeriodArray" , self )
1276
1276
self ._check_compatible_with (other )
1277
1277
1278
1278
other_i8 , o_mask = self ._get_i8_values_and_mask (other )
@@ -1478,7 +1478,7 @@ def __rsub__(self, other):
1478
1478
# TODO: Can we simplify/generalize these cases at all?
1479
1479
raise TypeError (f"cannot subtract { type (self ).__name__ } from { other .dtype } " )
1480
1480
elif lib .is_np_dtype (self .dtype , "m" ):
1481
- self = cast ("TimedeltaArray" , self ) # noqa: PLW0642
1481
+ self = cast ("TimedeltaArray" , self )
1482
1482
return (- self ) + other
1483
1483
1484
1484
# We get here with e.g. datetime objects
@@ -1697,7 +1697,7 @@ def _groupby_op(
1697
1697
1698
1698
if isinstance (self .dtype , PeriodDtype ):
1699
1699
raise TypeError ("'std' and 'sem' are not valid for PeriodDtype" )
1700
- self = cast ("DatetimeArray | TimedeltaArray" , self ) # noqa: PLW0642
1700
+ self = cast ("DatetimeArray | TimedeltaArray" , self )
1701
1701
new_dtype = f"m8[{ self .unit } ]"
1702
1702
res_values = res_values .view (new_dtype )
1703
1703
return TimedeltaArray ._simple_new (res_values , dtype = res_values .dtype )
@@ -2133,7 +2133,7 @@ def _ensure_matching_resos(self, other):
2133
2133
if self ._creso != other ._creso :
2134
2134
# Just as with Timestamp/Timedelta, we cast to the higher resolution
2135
2135
if self ._creso < other ._creso :
2136
- self = self .as_unit (other .unit ) # noqa: PLW0642
2136
+ self = self .as_unit (other .unit )
2137
2137
else :
2138
2138
other = other .as_unit (self .unit )
2139
2139
return self , other
@@ -2155,7 +2155,7 @@ def _round(self, freq, mode, ambiguous, nonexistent):
2155
2155
# round the local times
2156
2156
if isinstance (self .dtype , DatetimeTZDtype ):
2157
2157
# operate on naive timestamps, then convert back to aware
2158
- self = cast ("DatetimeArray" , self ) # noqa: PLW0642
2158
+ self = cast ("DatetimeArray" , self )
2159
2159
naive = self .tz_localize (None )
2160
2160
result = naive ._round (freq , mode , ambiguous , nonexistent )
2161
2161
return result .tz_localize (
0 commit comments