Skip to content

Commit 41f019b

Browse files
GH1089 Fix import
1 parent 5ee1dcc commit 41f019b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

pandas-stubs/core/series.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
19541954
level: Level | None = ...,
19551955
fill_value: float | None = ...,
19561956
axis: AxisIndex | None = ...,
1957-
) -> Series[S1]: ...
1957+
) -> Self: ...
19581958
def ge(
19591959
self,
19601960
other: Scalar | Series[S1],
@@ -2065,6 +2065,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
20652065
axis: AxisIndex | None = ...,
20662066
) -> Series[S1]: ...
20672067
@overload
2068+
def mul( # type: ignore[overload-overlap]
2069+
self,
2070+
other: Series[S1] | Self,
2071+
level: Level | None = ...,
2072+
fill_value: int | None = ...,
2073+
axis: AxisIndex | None = ...,
2074+
) -> Self: ...
2075+
@overload
20682076
def mul( # pyright: ignore[reportOverlappingOverload]
20692077
self: Series[int],
20702078
other: Series[int] | int,
@@ -2103,7 +2111,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
21032111
level: Level | None = ...,
21042112
fill_value: float | None = ...,
21052113
axis: AxisIndex | None = ...,
2106-
) -> Series: ...
2114+
) -> Self: ...
21072115
def multiply(
21082116
self,
21092117
other: num | _ListLike | Series[S1],

tests/test_series_arithmetic.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test module for arithmetic operations on Series."""
22

3+
from typing import cast
4+
35
import numpy as np
46
import pandas as pd
57
from typing_extensions import assert_type
@@ -188,3 +190,21 @@ def test_element_wise_float_float() -> None:
188190
check(
189191
assert_type(divmod(s, s2), tuple["pd.Series[float]", "pd.Series[float]"]), tuple
190192
)
193+
194+
195+
def test_element_wise_int_unknown() -> None:
196+
s = cast(pd.Series, pd.Series([7, -5, 10]))
197+
s2 = pd.Series([0, 1, -105])
198+
199+
check(assert_type(s + s2, pd.Series), pd.Series)
200+
check(assert_type(s.add(s2, fill_value=0), "pd.Series[float]"), pd.Series)
201+
202+
check(assert_type(s - s2, pd.Series), pd.Series)
203+
check(assert_type(s.sub(s2, fill_value=0), pd.Series), pd.Series)
204+
205+
check(assert_type(s * s2, pd.Series), pd.Series)
206+
check(assert_type(s.mul(s2, fill_value=0), pd.Series), pd.Series)
207+
208+
# GH1089 should be the following
209+
check(assert_type(s / s2, "pd.Series[float]"), pd.Series)
210+
check(assert_type(s.div(s2, fill_value=0), "pd.Series[float]"), pd.Series)

0 commit comments

Comments
 (0)