Skip to content

Commit d360eb6

Browse files
committed
TYP: Improve to_timedelta
1 parent 68e41e1 commit d360eb6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

pandas-stubs/core/tools/timedeltas.pyi

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# def to_timedelta(arg, unit: str = ..., errors: str = ...): ...
21
from datetime import timedelta
3-
from typing import overload
2+
from typing import (
3+
Sequence,
4+
overload,
5+
)
46

57
from pandas import Index
68
from pandas.core.indexes.timedeltas import TimedeltaIndex
@@ -16,11 +18,10 @@ from pandas._typing import (
1618
DateTimeErrorChoices,
1719
)
1820

19-
# Copied from pandas/_libs/tslibs/timedeltas.pyx
20-
2121
@overload
2222
def to_timedelta(
2323
arg: str | float | timedelta,
24+
# TODO: Check all UnitChoices are valid
2425
unit: UnitChoices | None = ...,
2526
errors: DateTimeErrorChoices = ...,
2627
) -> Timedelta: ...
@@ -32,7 +33,12 @@ def to_timedelta(
3233
) -> TimedeltaSeries: ...
3334
@overload
3435
def to_timedelta(
35-
arg: list | tuple | range | ArrayLike | Index,
36+
arg: Sequence[float | timedelta]
37+
| list[str | float | timedelta]
38+
| tuple[str | float | timedelta, ...]
39+
| range
40+
| ArrayLike
41+
| Index,
3642
unit: UnitChoices | None = ...,
3743
errors: DateTimeErrorChoices = ...,
3844
) -> TimedeltaIndex: ...

0 commit comments

Comments
 (0)