Skip to content

Commit ce1d7e1

Browse files
authored
Fix to_datetime([dt.date]) (#891) (#892)
1 parent 6b1da7c commit ce1d7e1

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

pandas-stubs/core/tools/datetimes.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def to_datetime(
8282
@overload
8383
def to_datetime(
8484
arg: (
85-
Sequence[float | datetime]
85+
Sequence[float | date]
8686
| list[str]
87-
| tuple[float | str | datetime, ...]
87+
| tuple[float | str | date, ...]
8888
| npt.NDArray[np.datetime64]
8989
| npt.NDArray[np.str_]
9090
| npt.NDArray[np.int_]

tests/test_timefuncs.py

+26
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,19 @@ def test_to_datetime_array() -> None:
10061006
),
10071007
pd.DatetimeIndex,
10081008
)
1009+
check(
1010+
assert_type(
1011+
pd.to_datetime(
1012+
[
1013+
dt.date(2000, 1, 1),
1014+
dt.date(2000, 1, 2),
1015+
dt.date(2000, 1, 3),
1016+
]
1017+
),
1018+
pd.DatetimeIndex,
1019+
),
1020+
pd.DatetimeIndex,
1021+
)
10091022
check(
10101023
assert_type(
10111024
pd.to_datetime(["2000-01-01", "2000-01-02", "2000-01-03"]), pd.DatetimeIndex
@@ -1029,6 +1042,19 @@ def test_to_datetime_array() -> None:
10291042
),
10301043
pd.DatetimeIndex,
10311044
)
1045+
check(
1046+
assert_type(
1047+
pd.to_datetime(
1048+
(
1049+
dt.date(2000, 1, 1),
1050+
dt.date(2000, 1, 2),
1051+
dt.date(2000, 1, 3),
1052+
)
1053+
),
1054+
pd.DatetimeIndex,
1055+
),
1056+
pd.DatetimeIndex,
1057+
)
10321058
check(
10331059
assert_type(
10341060
pd.to_datetime(("2000-01-01", "2000-01-02", "2000-01-03")), pd.DatetimeIndex

0 commit comments

Comments
 (0)