Skip to content

Commit cd62cb8

Browse files
authored
CLEAN: use preferred pattern for index accessors (#346)
* WIP: TimedeltaIndex accessors * remove dtl to make mypy happy * demonstrate possible bug
1 parent 903d6d7 commit cd62cb8

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

pandas-stubs/core/indexes/accessors.pyi

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ _DTRoundingMethodReturnType = TypeVar(
157157
TimedeltaSeries,
158158
TimestampSeries,
159159
DatetimeIndex,
160-
# TimedeltaIndex
160+
TimedeltaIndex,
161161
)
162162

163163
class _DatetimeRoundingMethods(Generic[_DTRoundingMethodReturnType]):
@@ -378,31 +378,8 @@ class DatetimeIndexProperties(
378378
self, axis: int | None = ..., ddof: int = ..., skipna: bool = ...
379379
) -> Timedelta: ...
380380

381-
# For some reason, using TimedeltaIndex as an argument to _DatetimeRoundingMethods
382-
# doesn't work for pyright. So we just make the rounding methods explicit here.
383381
class TimedeltaIndexProperties(
384382
Properties,
385383
_TimedeltaPropertiesNoRounding[Index, Index],
386-
# _DatetimeRoundingMethods[TimedeltaIndex],
387-
):
388-
def round(
389-
self,
390-
freq: str | BaseOffset | None,
391-
ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ...,
392-
nonexistent: Literal["shift_forward", "shift_backward", "NaT", "raise"]
393-
| Timedelta = ...,
394-
) -> TimedeltaIndex: ...
395-
def floor(
396-
self,
397-
freq: str | BaseOffset | None,
398-
ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ...,
399-
nonexistent: Literal["shift_forward", "shift_backward", "NaT", "raise"]
400-
| Timedelta = ...,
401-
) -> TimedeltaIndex: ...
402-
def ceil(
403-
self,
404-
freq: str | BaseOffset | None,
405-
ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ...,
406-
nonexistent: Literal["shift_forward", "shift_backward", "NaT", "raise"]
407-
| Timedelta = ...,
408-
) -> TimedeltaIndex: ...
384+
_DatetimeRoundingMethods[TimedeltaIndex],
385+
): ...

0 commit comments

Comments
 (0)