pandas-dev / pandas-stubs

Public type stubs for pandas
BSD 3-Clause "New" or "Revised" License
234 stars 125 forks source link

Add datetime.date and datetime.datetime specializations #1003

Closed alippai closed 1 month ago

alippai commented 2 months ago
twoertwein commented 2 months ago

Can you please add runtime tests in https://github.com/pandas-dev/pandas-stubs/blob/main/tests/test_timefuncs.py

You will also need to re-order the overloads to have the more specifiy overloads before more general overloads as type checker pick the first fitting overload (see the mypy errors).

alippai commented 2 months ago

@twoertwein thanks, I've updated the failing test and added the two cases brought up in the initial issue. Looks like datetime is a subclass of date so I just removed that, it could fix the overloads.

alippai commented 1 month ago

Looks like this is not possible to describe correctly: https://github.com/microsoft/pylance-release/issues/6512

Dr-Irv commented 1 month ago

Looks like this is not possible to describe correctly: microsoft/pylance-release#6512

I'm OK with putting in the appropriate #type: ignore and #pyright: ignore statements when the type checkers are reporting overlapping overloads.

alippai commented 1 month ago

@Dr-Irv thanks for the guide, I believe the last commit may work as intended and pass the CI