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

Issue:
error: Argument 1 to "mul" of "Series" has incompatible type "timedelta64" [arg-type]
**Describe the bug**

`Series.mul` has incompatible signature with `Series.__mul__`

**To Reproduce**

```python
import pandas as pd
import numpy as np

s = pd.Series([1, 2, 3])
x = s * np.timedelta64(1, "s")  # ✔
y = s.mul(np.timedelta64(1, "s") )  # ✘ [arg-type]
```


**Please complete the following information:**
 - OS: Ubuntu 22.04
 - python version 3.10
 - mypy 1.4.1
- pandas                        2.0.3
- pandas-stubs                  2.0.2.230605

error: Argument 1 to "mul" of "Series" has incompatible type "timedelta64" [arg-type]
**Describe the bug**

`Series.mul` has incompatible signature with `Series.__mul__`

**To Reproduce**

```python
import pandas as pd
import numpy as np

s = pd.Series([1, 2, 3])
x = s * np.timedelta64(1, "s")  # ✔
y = s.mul(np.timedelta64(1, "s") )  # ✘ [arg-type]
```


**Please complete the following information:**
 - OS: Ubuntu 22.04
 - python version 3.10
 - mypy 1.4.1
- pandas                        2.0.3
- pandas-stubs                  2.0.2.230605



Discussion / hints:
Need to coordinate the definitions of `Series.mul()` and `Series.__mul__()`, as well as tthe other operators (e.g., `add()` and `__add__()`, etc.
Need to coordinate the definitions of `Series.mul()` and `Series.__mul__()`, as well as tthe other operators (e.g., `add()` and `__add__()`, etc.

Fix patch:
diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi
index b6111db8..8da1c6ae 100644
--- a/pandas-stubs/core/series.pyi
+++ b/pandas-stubs/core/series.pyi
@@ -1573,6 +1573,11 @@ class Series(IndexOpsMixin[S1], NDFrame):
     def __rdivmod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...  # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
     def __rfloordiv__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
     def __rmod__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
+    @overload
+    def __rmul__(
+        self, other: timedelta | Timedelta | TimedeltaSeries | np.timedelta64
+    ) -> TimedeltaSeries: ...
+    @overload
     def __rmul__(self, other: num | _ListLike | Series) -> Series: ...
     def __rnatmul__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
     def __rpow__(self, other: num | _ListLike | Series[S1]) -> Series[S1]: ...
@@ -1794,13 +1799,22 @@ class Series(IndexOpsMixin[S1], NDFrame):
         fill_value: float | None = ...,
         axis: AxisIndex | None = ...,
     ) -> Series[S1]: ...
+    @overload
     def mul(
         self,
-        other: num | _ListLike | Series[S1],
+        other: timedelta | Timedelta | TimedeltaSeries | np.timedelta64,
         level: Level | None = ...,
         fill_value: float | None = ...,
         axis: AxisIndex | None = ...,
-    ) -> Series[S1]: ...
+    ) -> TimedeltaSeries: ...
+    @overload
+    def mul(
+        self,
+        other: num | _ListLike | Series,
+        level: Level | None = ...,
+        fill_value: float | None = ...,
+        axis: AxisIndex | None = ...,
+    ) -> Series: ...
     def multiply(
         self,
         other: num | _ListLike | Series[S1],
@@ -1869,13 +1883,22 @@ class Series(IndexOpsMixin[S1], NDFrame):
         fill_value: float | None = ...,
         axis: AxisIndex = ...,
     ) -> Series[S1]: ...
+    @overload
     def rmul(
         self,
-        other: Series[S1] | Scalar,
+        other: timedelta | Timedelta | TimedeltaSeries | np.timedelta64,
         level: Level | None = ...,
         fill_value: float | None = ...,
         axis: AxisIndex = ...,
-    ) -> Series[S1]: ...
+    ) -> TimedeltaSeries: ...
+    @overload
+    def rmul(
+        self,
+        other: num | _ListLike | Series,
+        level: Level | None = ...,
+        fill_value: float | None = ...,
+        axis: AxisIndex = ...,
+    ) -> Series: ...
     @overload
     def rolling(
         self,


Test patch:
diff --git a/tests/test_series.py b/tests/test_series.py
index efd368f8..42de32de 100644
--- a/tests/test_series.py
+++ b/tests/test_series.py
@@ -3214,3 +3214,28 @@ def test_diff_never3() -> None:
     if TYPE_CHECKING_INVALID_USAGE:
         # str -> TypeError: unsupported operand type(s) for -: 'str' and 'str'
         assert_never(pd.Series(["a", "b"]).diff())
+
+
+def test_operator_constistency() -> None:
+    # created for #748
+    s = pd.Series([1, 2, 3])
+    check(
+        assert_type(s * np.timedelta64(1, "s"), "TimedeltaSeries"),
+        pd.Series,
+        pd.Timedelta,
+    )
+    check(
+        assert_type(np.timedelta64(1, "s") * s, "TimedeltaSeries"),
+        pd.Series,
+        pd.Timedelta,
+    )
+    check(
+        assert_type(s.mul(np.timedelta64(1, "s")), "TimedeltaSeries"),
+        pd.Series,
+        pd.Timedelta,
+    )
+    check(
+        assert_type(s.rmul(np.timedelta64(1, "s")), "TimedeltaSeries"),
+        pd.Series,
+        pd.Timedelta,
+    )