Skip to content

Conversation

@loicdiridollou
Copy link
Member

  • Closes Series[Any] should accept __add__ #1541
  • Tests added (Please use assert_type() to assert the type of any return value)
  • If I used AI to develop this pull request, I prompted it to follow AGENTS.md.

@loicdiridollou loicdiridollou requested review from Dr-Irv and cmp0xff and removed request for Dr-Irv December 10, 2025 21:55
# them up.
@overload
def __add__(self: Series[Never], other: complex | ListLike) -> Series: ...
def __add__(self: Series[Never], other: _str | complex | ListLike) -> Series: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create an overload that says if other: _str, the result is Series[str] ?

Comment on lines +4083 to +4090


def test_series_add_str() -> None:
"""Test Series.__add__ with Series[Any]."""
df = pd.DataFrame({0: ["a", "b"]})
sr = df[0]

check(assert_type(sr + "c1", pd.Series), pd.Series, str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plesae move the new test to tests\series\arithmetic\test_add.py and make use of left_str.

Probably we need to make the same valid tests in tests\series\arithmetic\str\test_add.py (excluding the TYPE_CHECKING_INVALID_USAGE ones) work for Series[Any].

For consistency, we probably also need to make Index[Any] + str etc. work

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 this pull request may close these issues.

Series[Any] should accept __add__

3 participants