Skip to content

No overload variant of "__sub__" of "Series" matches argument type "Timedelta" #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WillAyd opened this issue Aug 1, 2023 · 1 comment · Fixed by #759
Closed

No overload variant of "__sub__" of "Series" matches argument type "Timedelta" #758

WillAyd opened this issue Aug 1, 2023 · 1 comment · Fixed by #759

Comments

@WillAyd
Copy link
Member

WillAyd commented Aug 1, 2023

Describe the bug
After upgrading to pandas 2.0 started getting errors as described in the title

To Reproduce

import pandas as pd

df = pd.read_csv("afile.csv", parse_dates=["foo"])
df["foo"] = df["foo"] - pd.Timedelta("1D")

Using mypy:

pandas-stubs-mre.py:4: error: No overload variant of "__sub__" of "Series" matches argument type "Timedelta"  [operator]
pandas-stubs-mre.py:4: note: Possible overload variants:
pandas-stubs-mre.py:4: note:     def __sub__(self, Timestamp | datetime | TimestampSeries, /) -> TimedeltaSeries
pandas-stubs-mre.py:4: note:     def __sub__(self, complex | ExtensionArray | ndarray[Any, Any] | dict[str, ndarray[Any, Any]] | list[Any] | tuple[Any, ...] | Index | Series[Any], /) -> Series[Any]
Found 1 error in 1 file (checked 1 source file)

Please complete the following information:

  • OS: Discovered on both Windows / Linux
  • python version: 3.11.0
  • version of type checker: mypy 1.4.1 (compiled: yes)
  • version of installed pandas-stubs: 2.0.2.230605

Additional context
The issue does not happen with older versions of pandas-stubs - 1.5.3.230321 issues no complaint. I haven't done a full bisect but guess this may go back to #616 ?

@Dr-Irv Dr-Irv mentioned this issue Aug 2, 2023
2 tasks
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 2, 2023

Thanks @WillAyd . This was bugging me too. I think there was an intermediate version of mypy that required #616 but now I put that code back in #759 and my local tests passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants