Skip to content

Commit 1de98d2

Browse files
committed
added right order of __add__ overlay and testcases
1 parent 23b588c commit 1de98d2

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

pandas-stubs/core/series.pyi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,9 +1577,19 @@ class Series(IndexOpsMixin[S1], NDFrame):
15771577
# just failed to generate these so I couldn't match
15781578
# them up.
15791579
@overload
1580-
def __add__(self, other: S1 | Self) -> Self: ...
1580+
def __add__(self: Series[int], other: int) -> Series[int]: ...
1581+
@overload
1582+
def __add__(self: Series[int], other: float) -> Series[float]: ...
1583+
@overload
1584+
def __add__(self: Series[int], other: complex) -> Series[complex]: ...
1585+
@overload
1586+
def __add__(self: Series[float], other: int) -> Series[float]: ...
15811587
@overload
1582-
def __add__(self, other: complex) -> Series[complex]: ...
1588+
def __add__(self: Series[float], other: float) -> Series[float]: ...
1589+
@overload
1590+
def __add__(self: Series[float], other: complex) -> Series[complex]: ...
1591+
@overload
1592+
def __add__(self, other: S1 | Self) -> Self: ...
15831593
@overload
15841594
def __add__(
15851595
self,

tests/test_series.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,6 +3543,14 @@ def test_series_add_complex() -> None:
35433543
s = pd.Series([1.0, 2.0, 3.0])
35443544
check(assert_type(s + c, "pd.Series[complex]"), pd.Series)
35453545

3546+
c1 = 1
3547+
s1 = pd.Series([1.0, 2.0, 3.0])
3548+
check(assert_type(s1 + c1, "pd.Series[float]"), pd.Series)
3549+
3550+
c2 = 1
3551+
s2 = pd.Series([1, 2, 3])
3552+
check(assert_type(s2 + c2, "pd.Series[int]"), pd.Series)
3553+
35463554

35473555
def test_series_reindex_like() -> None:
35483556
s = pd.Series([1, 2, 3], index=[0, 1, 2])

0 commit comments

Comments
 (0)