Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8a99cf4
refactor: only drop TimestampSeries https://github.com/pandas-dev/pan…
cmp0xff Jul 13, 2025
ed69ec5
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274/fi…
cmp0xff Jul 28, 2025
f1cf19f
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Aug 2, 2025
ad0ee10
less mypy ignore
cmp0xff Aug 4, 2025
2dada6d
fix: even less mypy ignores
cmp0xff Aug 5, 2025
0359fd5
refactor(comment): https://github.com/pandas-dev/pandas-stubs/pull/12…
cmp0xff Aug 5, 2025
34703d7
feat: sub
cmp0xff Aug 5, 2025
c4d657e
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274/fi…
cmp0xff Aug 6, 2025
1eeb809
fix: pyrefly
cmp0xff Aug 6, 2025
ceff1fe
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274/fi…
cmp0xff Aug 6, 2025
dd8baff
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274#di…
cmp0xff Aug 6, 2025
8a07eca
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274#di…
cmp0xff Aug 6, 2025
3458fc9
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274#di…
cmp0xff Aug 6, 2025
d333902
fix: reduce ignore
cmp0xff Aug 6, 2025
368c3ff
refactor: explain a temporary failure
cmp0xff Aug 7, 2025
2f661ae
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Aug 7, 2025
15996ff
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274#di…
cmp0xff Aug 7, 2025
c9c46b0
feat: arithmetic sub
cmp0xff Aug 8, 2025
e3447cf
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1312#di…
cmp0xff Aug 8, 2025
672009e
feat(comment): https://github.com/pandas-dev/pandas-stubs/pull/1312#d…
cmp0xff Aug 11, 2025
5dab881
Merge branch 'main' into feature/cmp0xff/arithmetic-sub
cmp0xff Aug 14, 2025
1e9b11d
fix(comment): completeness https://github.com/pandas-dev/pandas-stubs…
cmp0xff Aug 14, 2025
6484af7
feat(series): arithmetic mul
cmp0xff Aug 8, 2025
72c2bd1
Merge branch 'feature/cmp0xff/arithmetic-mul' into hotfix/cmp0xff/gh7…
cmp0xff Aug 16, 2025
0657417
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Aug 19, 2025
7a87d18
fix: type asserts
cmp0xff Aug 20, 2025
6469196
feat: tests for addition
cmp0xff Aug 20, 2025
aac6cff
fix(mypy): attempt for python > 310
cmp0xff Aug 20, 2025
72208c7
feat: tests for subtraction
cmp0xff Aug 20, 2025
533b15d
fix: pyright
cmp0xff Aug 20, 2025
ce06dc2
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274#di…
cmp0xff Aug 20, 2025
f855f86
refactor: revert unused design
cmp0xff Aug 20, 2025
8a01e12
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Aug 22, 2025
0a84cd0
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Aug 27, 2025
253e61a
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Sep 2, 2025
f736d55
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Sep 4, 2025
3ff2c36
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Sep 11, 2025
f10e990
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Sep 13, 2025
4e5e68c
feat: progressive philosophy
cmp0xff Sep 13, 2025
55fdfe9
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
cmp0xff Sep 14, 2025
6572abc
fix(pytest): remove invalid tests
cmp0xff Sep 15, 2025
7b380b3
fix: comment
cmp0xff Sep 15, 2025
e7705e4
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274/fi…
cmp0xff Sep 15, 2025
b487bc9
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274#di…
cmp0xff Sep 15, 2025
ff37521
chore(philosophy): first draft
cmp0xff Sep 15, 2025
61a9703
fix(pyright): median
cmp0xff Sep 15, 2025
e2b1901
fix: comment
cmp0xff Sep 16, 2025
a488907
fix(comment): https://github.com/pandas-dev/pandas-stubs/pull/1274#pu…
cmp0xff Sep 17, 2025
a0ae00d
fix(comment): test_sub
cmp0xff Sep 17, 2025
ed7de8d
fix: typo
cmp0xff Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions attempt.py

This file was deleted.

14 changes: 14 additions & 0 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,13 @@ class Series(IndexOpsMixin[S1], NDFrame):
self: Series[_T_COMPLEX], other: np_ndarray_complex
) -> Series[complex]: ...
@overload
def __add__(
self: Series[_str],
other: (
np_ndarray_bool | np_ndarray_anyint | np_ndarray_float | np_ndarray_complex
),
) -> Never: ...
@overload
def __add__(
self: Series[_str], other: _str | Sequence[_str] | np_ndarray_str | Series[_str]
) -> Series[_str]: ...
Expand Down Expand Up @@ -1951,6 +1958,13 @@ class Series(IndexOpsMixin[S1], NDFrame):
self: Series[_T_COMPLEX], other: np_ndarray_complex
) -> Series[complex]: ...
@overload
def __radd__(
self: Series[_str],
other: (
np_ndarray_bool | np_ndarray_anyint | np_ndarray_float | np_ndarray_complex
),
) -> Never: ...
@overload
def __radd__(
self: Series[_str], other: _str | Sequence[_str] | np_ndarray_str | Series[_str]
) -> Series[_str]: ...
Expand Down
56 changes: 52 additions & 4 deletions tests/series/arithmetic/str/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,119 @@
import numpy as np
from numpy import typing as npt # noqa: F401
import pandas as pd
from typing_extensions import assert_type
from typing_extensions import (
Never,
assert_type,
)

from tests import check
from tests import (
TYPE_CHECKING_INVALID_USAGE,
check,
)

left = pd.Series(["1", "23", "456"]) # left operand


def test_add_py_scalar() -> None:
"""Testpd.Series[str]+ Python native str"""
"""Testpd.Series[str]+ Python native 'scalar's"""
i = 4
r0 = "right"

if TYPE_CHECKING_INVALID_USAGE:
_0 = left + i # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
_1 = i + left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
check(assert_type(r0 + left, "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.add(i) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.radd(i) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str)


def test_add_py_sequence() -> None:
"""Testpd.Series[str]+ Python native sequence"""
i = [3, 5, 8]
r0 = ["a", "bc", "def"]
r1 = tuple(r0)

if TYPE_CHECKING_INVALID_USAGE:
_0 = left + i # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str)
check(assert_type(left + r1, "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
_1 = i + left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
check(assert_type(r0 + left, "pd.Series[str]"), pd.Series, str)
check(assert_type(r1 + left, "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.add(i) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str)
check(assert_type(left.add(r1), "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.radd(i) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str)
check(assert_type(left.radd(r1), "pd.Series[str]"), pd.Series, str)


def test_add_numpy_array() -> None:
"""Testpd.Series[str]+ numpy array"""
i = np.array([3, 5, 8], np.int64)
r0 = np.array(["a", "bc", "def"], np.str_)

if TYPE_CHECKING_INVALID_USAGE:
assert_type(left + i, Never)
check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str)

# `numpy` typing gives `npt.NDArray[np.str_]` in the static type
# `numpy` typing gives `npt.NDArray[np.int64]` in the static type
# checking, where our `__radd__` cannot override. At runtime, they return
# `Series`s.
if TYPE_CHECKING_INVALID_USAGE:
assert_type(i + left, "npt.NDArray[np.int64]")
if sys.version_info >= (3, 11):
# `numpy` typing gives `npt.NDArray[np.int64]` in the static type
# checking, where our `__radd__` cannot override. At runtime, they return
# `Series`s.
check(assert_type(r0 + left, "npt.NDArray[np.str_]"), pd.Series, str)
else:
# Python 3.10 uses NumPy 2.2.6, and it has for r0 ndarray[tuple[int,...], dtype[str_]]
# Python 3.11+ uses NumPy 2.3.2, and it has for r0 ndarray[tuple[Any,...,dtype[str_]]
# https://github.com/pandas-dev/pandas-stubs/pull/1274#discussion_r2291498975
check(assert_type(r0 + left, Any), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.add(i) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.radd(i) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str)


def test_add_pd_series() -> None:
"""Testpd.Series[str]+ pandas series"""
i = pd.Series([3, 5, 8])
r0 = pd.Series(["a", "bc", "def"])

if TYPE_CHECKING_INVALID_USAGE:
_0 = left + i # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
_1 = i + left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
check(assert_type(r0 + left, "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.add(i) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str)

if TYPE_CHECKING_INVALID_USAGE:
left.radd(i) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str)
1 change: 0 additions & 1 deletion tests/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,6 @@ def test_series_min_max_sub_axis() -> None:
ss = s1 - s2
sm = s1 * s2
sd = s1 / s2
s1.__sub__(s2)
check(assert_type(sa, pd.Series), pd.Series)
check(assert_type(ss, pd.Series), pd.Series)
check(assert_type(sm, pd.Series), pd.Series)
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.