GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TYP: add Series.add/radd keywords and sequence addition by cmp0xff · Pull Request #46 · cmp0xff/pandas-stubs

Conversation

@cmp0xff

@cmp0xff cmp0xff commented Nov 3, 2026

Copy link
Copy Markdown
Owner
  • Closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added (Please use assert_type() to assert the type of any return value)
  • If I add a new API, it is already listed as public in the pandas API reference.
  • If I used AI to develop this pull request, I prompted it to follow AGENTS.md.

Draft split of the part of pandas-dev#1914 that does not depend on the Series[Never] workaround.

  • level/fill_value/axis keywords and add/__add__, radd/__radd__ symmetry
  • Sequence addition per ENH: arithmetic between DatetimeArray / TimedeltaArray and list pandas-dev/pandas#62353, with the result bound S2_NSDT
  • Timestamp/Timedelta overloads share the ScalarArrayIndexSeries* aliases
  • Test dedup in tests/test_timefuncs.py; Series[Period] and offsets are left out

🤖 Generated with Claude Code

AI Implementation Plan

Status

Draft, parked for a later session. Local checks on this branch: mypy, pyright, pyrefly, pytest and style pass. ty reports no errors, only 24 unused # ty: ignore warnings in tests/series/test_series.py and tests/arrays/test_numpy_.py (files this diff does not touch); not yet confirmed to be present on plain main (likely checker-version drift, since poetry.lock is gitignored).

Why pandas-dev#1914 was closed and split

  • Handle overloaded method ambiguity caused by self-types python/mypy#22011 (merged 2026-10-11, not yet released, expected in 2.5), astral-sh/ty#29342 (merged 2026-10-14) and Retain alternatives for specialized instance-method overloads microsoft/pyright#11864 (merged 2026-10-15) make overloads on Series[Any] ambiguous, so the self: Series[Never] workaround stops working. Specialised-self overloads select the first match for a gradual receiver pyrefly-org/pyrefly#5205 is an open issue. All four checkers converge on the same behaviour, so waiting for releases and reopening has no good outcome.
  • TYP: allow floor division of Series[Any] by a timedelta scalar pandas-dev/pandas-stubs#1968 discussed it. Agreed direction: make the methods accept wider arguments instead of relying on Series[Never].
  • TYP: #1378 align Series __add__ family with __mul__ pandas-dev/pandas-stubs#1914 adds no new Series[Never] overloads (count identical on main and its head) but widens four existing ones and adds a Series[Period] overload that also matches a Series[Any] receiver; ty already infers Unknown there.
  • Do not pin mypy<2.5 to protect this work: it only delays a failure that hits main anyway.

What this PR contains

  • Series add family: keywords (level, fill_value, axis), add/__add__ and radd/__radd__ kept in step, Timestamp/Timedelta overloads via ScalarArrayIndexSeriesTimedelta / new ScalarArrayIndexSeriesDatetime, str overloads moved ahead of the protocol ones.
  • Sequence addition (ENH: arithmetic between DatetimeArray / TimedeltaArray and list pandas-dev/pandas#62353): Series[S2_contra] with SupportsRAdd[S2_contra, S2_NSDT] | Sequence[...], mirrored on radd/__radd__.
  • Tests: keyword coverage in tests/series/test_add.py and the timedelta/timestamp packages; superseded cases removed from tests/test_timefuncs.py; tests/frame/test_frame.py TODO now points to overloads resolved as a conflict with Any astral-sh/ty#4055.
  • Merge note: the original patch conflicted with upstream's newer series.pyi; a stale __radd__ tail using S2_NDT_contra was removed by hand.

Deliberately left out (ideas for follow-ups)

  • Series[Period] __add__/add/__radd__/radd overload, ScalarArrayIndexSeriesPeriod alias and tests/series/period/test_add.py (preserved on the align-add-family branch).
  • The four complex | ListLike | Index | Series widenings on the Series[Never] overloads.
  • Offset arithmetic (deferred to TYP: widen delta offset __add__/__radd__ operands pandas-dev/pandas-stubs#1943).
  • Redesign: one repo-wide issue on retiring self: Series[Never], linking the four checker references above, with wider-signature replacements. Offer to take it or comment on it.

Open items / to-do

  • Confirm the 24 ty unused-ignore warnings also appear on plain main.
  • mypy-master run to confirm no new Handle overloaded method ambiguity caused by self-types python/mypy#22011 errors versus a main baseline.
  • Copilot's finding on TYP: #1378 align Series __add__ family with __mul__ pandas-dev/pandas-stubs#1914: S2_NSDT omits datetime.date, so date-Series addition might regress. Not reproduced: pyright gives identical errors on main and this branch for Series[date] + [timedelta] and .add([timedelta]) (annotate the series explicitly: pyright infers Series[Timestamp] from pd.Series([date(...)])). Try mypy and other date inputs before dropping or widening the bound.
  • Open an issue and fill Closes #xxxx before any upstream PR; drop the draft state only after the final push and green checks.
  • Upstream PR must not link the fork; use full pandas-dev/pandas-stubs#n references.

Verification commands

poetry install, then poetry run poe test_all (aborts at the first failing step; ty runs first here, so run mypy, pyright, pyrefly, pytest, style separately to see past it).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cmp0xff @claude
TYP: add Series.add/radd keywords and sequence addition
4d65b5a
Co-authored-by: claude-sonnet-5-5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@cmp0xff
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.