Repository: pandas-dev/pandas-stubs (language: python)

Issue:
pd.to_datetime(list[datetime.date]) is wrong input type (mypy), but pandas returns output.
**Describe the bug**
`datetime.date` is a valid type as a function parameter, but mypy raises errors

**To Reproduce**

`test.py` file:
```py
from datetime import date
import pandas as pd

dates = [date.today(), date.today()]
dates = pd.to_datetime(dates)
```
in dates is `DatetimeIndex(['2024-03-19', '2024-03-19'], dtype='datetime64[ns]', freq=None)`

But mypy returns:
```sh
# mypy test.py
test.py:5: error: Incompatible types in assignment (expression has type "DatetimeIndex", variable has type "list[date]")  [assignment]
test.py:5: error: Argument 1 to "to_datetime" has incompatible type "list[date]"; expected "Sequence[float | datetime] | list[str] | tuple[float | str | datetime, ...] | ndarray[Any, dtype[datetime64]] | ndarray[Any, dtype[str_]] | ndarray[Any, dtype[signedinteger[Any]]] | Index[Any] | ExtensionArray"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)
```

**Please complete the following information:**
 - OS: Linux Ubuntu 22.04.4 LTS x86_64
 - python version 3.10.13
 - version of type checker: mypy 1.7.1 (compiled: yes)
 - version of installed `pandas-stubs`: 2.2.0.240218
 - pandas 2.2.1



Discussion / hints:
Thanks for the report.

Need to change `datetime` to `date` in this line:
https://github.com/pandas-dev/pandas-stubs/blob/6b1da7cfb9d66db600d4f9bb6ef069003b81c75a/pandas-stubs/core/tools/datetimes.pyi#L85

and 2 lines below that, since `datetime` is a subclass of `date`

PR welcome with tests in `test_pandas.py`

Fix patch:
diff --git a/pandas-stubs/core/tools/datetimes.pyi b/pandas-stubs/core/tools/datetimes.pyi
index 94189b61..2ee995f1 100644
--- a/pandas-stubs/core/tools/datetimes.pyi
+++ b/pandas-stubs/core/tools/datetimes.pyi
@@ -82,9 +82,9 @@ def to_datetime(
 @overload
 def to_datetime(
     arg: (
-        Sequence[float | datetime]
+        Sequence[float | date]
         | list[str]
-        | tuple[float | str | datetime, ...]
+        | tuple[float | str | date, ...]
         | npt.NDArray[np.datetime64]
         | npt.NDArray[np.str_]
         | npt.NDArray[np.int_]


Test patch:
diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py
index dd66aa54..13176f3d 100644
--- a/tests/test_timefuncs.py
+++ b/tests/test_timefuncs.py
@@ -1006,6 +1006,19 @@ def test_to_datetime_array() -> None:
         ),
         pd.DatetimeIndex,
     )
+    check(
+        assert_type(
+            pd.to_datetime(
+                [
+                    dt.date(2000, 1, 1),
+                    dt.date(2000, 1, 2),
+                    dt.date(2000, 1, 3),
+                ]
+            ),
+            pd.DatetimeIndex,
+        ),
+        pd.DatetimeIndex,
+    )
     check(
         assert_type(
             pd.to_datetime(["2000-01-01", "2000-01-02", "2000-01-03"]), pd.DatetimeIndex
@@ -1029,6 +1042,19 @@ def test_to_datetime_array() -> None:
         ),
         pd.DatetimeIndex,
     )
+    check(
+        assert_type(
+            pd.to_datetime(
+                (
+                    dt.date(2000, 1, 1),
+                    dt.date(2000, 1, 2),
+                    dt.date(2000, 1, 3),
+                )
+            ),
+            pd.DatetimeIndex,
+        ),
+        pd.DatetimeIndex,
+    )
     check(
         assert_type(
             pd.to_datetime(("2000-01-01", "2000-01-02", "2000-01-03")), pd.DatetimeIndex