You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gwerbin-tive
changed the title
BUG: Type stubs only support pd.Timedelta, but could also support datetime.timedelta
BUG: Type stubs only support pd.Timedelta, but could (should?) also support datetime.timedelta
Dec 22, 2023
Thanks for the report. In pandas-stubs/core/indexes/datetimes.pyi, have to change the arithmetic methods that accept Timedelta as an argument to use timedelta instead, since pd.Timedelta is a subclass of datetime.timedelta.
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
typ.py
:Output, showing the expected result:
Mypy config in
pyproject.toml
:Issue Description
The type stubs don't recognize
datetime.timedelta
as a valid operand:Expected Behavior
I expected this to pass type-checking, because it works fine at runtime and is officially supported behavior (as far as I know).
If this isn't meant to be supported and only works by coincidence, then I apologize for the noise and feel free to close.
I did notice that
pd.Timedelta
is a subclass ofdatetime.timedelta
, so this should be a really easy change.I looked around for a while and didn't find the type stubs for this particular method, otherwise I would have just submitted a patch straight away.
Installed Versions
The text was updated successfully, but these errors were encountered: