From df9448326787363fb141c165a34e2332bc7feaf8 Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Thu, 9 Oct 2025 15:31:01 +0200 Subject: [PATCH] Revert "fix(comment): pandas-dev/pandas#62595 https://github.com/pandas-dev/pandas-stubs/pull/1397#discussion_r2404737078" This reverts commit 5da6b1cd9b17b7fb84c836bda9096e101c8ce8db. --- pandas-stubs/core/indexes/base.pyi | 38 +++++----- pandas-stubs/core/series.pyi | 52 ++++++-------- tests/indexes/arithmetic/str/test_mul.py | 41 +++++------ tests/series/arithmetic/str/test_mul.py | 89 +++++++++++------------- 4 files changed, 93 insertions(+), 127 deletions(-) diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index b41353ef4..7b94a5090 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -784,21 +784,18 @@ class Index(IndexOpsMixin[S1]): @overload def __mul__( self: Index[_str], - other: np_ndarray_float | np_ndarray_complex | np_ndarray_dt | np_ndarray_td, + other: ( + np_ndarray_bool + | np_ndarray_float + | np_ndarray_complex + | np_ndarray_dt + | np_ndarray_td + ), ) -> Never: ... - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x @overload def __mul__( self: Index[_str], - other: ( - int - | Sequence[int] - | np_ndarray_bool - | np_ndarray_anyint - | Index[bool] - | Index[int] - ), + other: Just[int] | Sequence[Just[int]] | np_ndarray_anyint | Index[int], ) -> Index[_str]: ... @overload def __mul__(self: Index[T_INT], other: bool | Sequence[bool]) -> Index[T_INT]: ... @@ -877,21 +874,18 @@ class Index(IndexOpsMixin[S1]): @overload def __rmul__( self: Index[_str], - other: np_ndarray_float | np_ndarray_complex | np_ndarray_dt | np_ndarray_td, + other: ( + np_ndarray_bool + | np_ndarray_float + | np_ndarray_complex + | np_ndarray_dt + | np_ndarray_td + ), ) -> Never: ... - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x @overload def __rmul__( self: Index[_str], - other: ( - int - | Sequence[int] - | np_ndarray_bool - | np_ndarray_anyint - | Index[bool] - | Index[int] - ), + other: Just[int] | Sequence[Just[int]] | np_ndarray_anyint | Index[int], ) -> Index[_str]: ... @overload def __rmul__(self: Index[T_INT], other: bool | Sequence[bool]) -> Index[T_INT]: ... diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 9b41a239c..3bbf0c81a 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -2586,21 +2586,22 @@ class Series(IndexOpsMixin[S1], NDFrame): @overload def __mul__( self: Series[_str], - other: np_ndarray_float | np_ndarray_complex | np_ndarray_dt | np_ndarray_td, + other: ( + np_ndarray_bool + | np_ndarray_float + | np_ndarray_complex + | np_ndarray_dt + | np_ndarray_td + ), ) -> Never: ... - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x @overload def __mul__( self: Series[_str], other: ( - int - | Sequence[int] - | np_ndarray_bool + Just[int] + | Sequence[Just[int]] | np_ndarray_anyint - | Index[bool] | Index[int] - | Series[bool] | Series[int] ), ) -> Series[_str]: ... @@ -2696,19 +2697,14 @@ class Series(IndexOpsMixin[S1], NDFrame): fill_value: float | None = None, axis: AxisIndex | None = 0, ) -> Series[Timedelta]: ... - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x @overload def mul( self: Series[_str], other: ( - int - | Sequence[int] - | np_ndarray_bool + Just[int] + | Sequence[Just[int]] | np_ndarray_anyint - | Index[bool] | Index[int] - | Series[bool] | Series[int] ), level: Level | None = None, @@ -2843,21 +2839,22 @@ class Series(IndexOpsMixin[S1], NDFrame): @overload def __rmul__( self: Series[_str], - other: np_ndarray_float | np_ndarray_complex | np_ndarray_dt | np_ndarray_td, + other: ( + np_ndarray_bool + | np_ndarray_float + | np_ndarray_complex + | np_ndarray_dt + | np_ndarray_td + ), ) -> Never: ... - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x @overload def __rmul__( self: Series[_str], other: ( - int - | Sequence[int] - | np_ndarray_bool + Just[int] + | Sequence[Just[int]] | np_ndarray_anyint - | Index[bool] | Index[int] - | Series[bool] | Series[int] ), ) -> Series[_str]: ... @@ -2955,19 +2952,14 @@ class Series(IndexOpsMixin[S1], NDFrame): fill_value: float | None = None, axis: AxisIndex | None = 0, ) -> Series[Timedelta]: ... - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x @overload def rmul( self: Series[_str], other: ( - int - | Sequence[int] - | np_ndarray_bool + Just[int] + | Sequence[Just[int]] | np_ndarray_anyint - | Index[bool] | Index[int] - | Series[bool] | Series[int] ), level: Level | None = None, diff --git a/tests/indexes/arithmetic/str/test_mul.py b/tests/indexes/arithmetic/str/test_mul.py index 2f1b45bfd..bc3aade00 100644 --- a/tests/indexes/arithmetic/str/test_mul.py +++ b/tests/indexes/arithmetic/str/test_mul.py @@ -14,7 +14,6 @@ ) from tests import ( - PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, ) @@ -32,10 +31,8 @@ def test_mul_py_scalar(left: "pd.Index[str]") -> None: b, i, f, c = True, 1, 1.0, 1j s, d = datetime(2025, 9, 27), timedelta(seconds=1) - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Index[str]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(left * i, "pd.Index[str]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -43,8 +40,8 @@ def test_mul_py_scalar(left: "pd.Index[str]") -> None: _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(b * left, "pd.Index[str]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(i * left, "pd.Index[str]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -59,10 +56,8 @@ def test_mul_py_sequence(left: "pd.Index[str]") -> None: s = [datetime(2025, 9, d) for d in (27, 28, 29)] d = [timedelta(seconds=s + 1) for s in range(3)] - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Index[str]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(left * i, "pd.Index[str]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -70,8 +65,8 @@ def test_mul_py_sequence(left: "pd.Index[str]") -> None: _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(b * left, "pd.Index[str]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(i * left, "pd.Index[str]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -89,10 +84,8 @@ def test_mul_numpy_array(left: "pd.Index[str]") -> None: s = np.array([np.datetime64(f"2025-09-{d}") for d in (27, 28, 29)], np.datetime64) d = np.array([np.timedelta64(s + 1, "s") for s in range(3)], np.timedelta64) - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Index[str]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + assert_type(left * b, Never) check(assert_type(left * i, "pd.Index[str]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: assert_type(left * f, Never) @@ -103,8 +96,8 @@ def test_mul_numpy_array(left: "pd.Index[str]") -> None: # `numpy` typing gives the corresponding `ndarray`s in the static type # checking, where our `__rmul__` cannot override. At runtime, they return # `Index` with the correct element type. - if PD_LTE_23: - check(assert_type(b * left, "npt.NDArray[np.bool_]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + assert_type(b * left, "npt.NDArray[np.bool_]") check(assert_type(i * left, "npt.NDArray[np.int64]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: assert_type(f * left, "npt.NDArray[np.float64]") @@ -122,10 +115,8 @@ def test_mul_pd_index(left: "pd.Index[str]") -> None: s = pd.Index([datetime(2025, 9, d) for d in (27, 28, 29)]) d = pd.Index([timedelta(seconds=s + 1) for s in range(3)]) - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Index[str]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(left * i, "pd.Index[str]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -133,8 +124,8 @@ def test_mul_pd_index(left: "pd.Index[str]") -> None: _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(b * left, "pd.Index[str]"), pd.Index, str) + if TYPE_CHECKING_INVALID_USAGE: + _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(i * left, "pd.Index[str]"), pd.Index, str) if TYPE_CHECKING_INVALID_USAGE: _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] diff --git a/tests/series/arithmetic/str/test_mul.py b/tests/series/arithmetic/str/test_mul.py index 2d7d60efc..1d562db75 100644 --- a/tests/series/arithmetic/str/test_mul.py +++ b/tests/series/arithmetic/str/test_mul.py @@ -14,7 +14,6 @@ ) from tests import ( - PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, ) @@ -32,10 +31,8 @@ def test_mul_py_scalar(left: "pd.Series[str]") -> None: b, i, f, c = True, 1, 1.0, 1j s, d = datetime(2025, 9, 27), timedelta(seconds=1) - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(left * i, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -43,8 +40,8 @@ def test_mul_py_scalar(left: "pd.Series[str]") -> None: _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(b * left, "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(i * left, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -52,22 +49,22 @@ def test_mul_py_scalar(left: "pd.Series[str]") -> None: _14 = s * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _15 = d * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(left.mul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.mul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.mul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.mul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.mul(c) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] - left.mul(s) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] + left.mul(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.mul(d) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] - if PD_LTE_23: - check(assert_type(left.rmul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.rmul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.rmul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.rmul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.rmul(c) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] - left.rmul(s) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] + left.rmul(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.rmul(d) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -77,10 +74,8 @@ def test_mul_py_sequence(left: "pd.Series[str]") -> None: s = [datetime(2025, 9, d) for d in (27, 28, 29)] d = [timedelta(seconds=s + 1) for s in range(3)] - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(left * i, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -88,8 +83,8 @@ def test_mul_py_sequence(left: "pd.Series[str]") -> None: _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(b * left, "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(i * left, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -97,8 +92,8 @@ def test_mul_py_sequence(left: "pd.Series[str]") -> None: _14 = s * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _15 = d * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(left.mul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.mul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.mul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.mul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -106,8 +101,8 @@ def test_mul_py_sequence(left: "pd.Series[str]") -> None: left.mul(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.mul(d) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] - if PD_LTE_23: - check(assert_type(left.rmul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.rmul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.rmul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.rmul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -125,10 +120,8 @@ def test_mul_numpy_array(left: "pd.Series[str]") -> None: s = np.array([np.datetime64(f"2025-09-{d}") for d in (27, 28, 29)], np.datetime64) d = np.array([np.timedelta64(s + 1, "s") for s in range(3)], np.timedelta64) - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + assert_type(left * b, Never) check(assert_type(left * i, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: assert_type(left * f, Never) @@ -139,8 +132,8 @@ def test_mul_numpy_array(left: "pd.Series[str]") -> None: # `numpy` typing gives the corresponding `ndarray`s in the static type # checking, where our `__rmul__` cannot override. At runtime, they return # `Series` with the correct element type. - if PD_LTE_23: - check(assert_type(b * left, "npt.NDArray[np.bool_]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + assert_type(b * left, "npt.NDArray[np.bool_]") check(assert_type(i * left, "npt.NDArray[np.int64]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: assert_type(f * left, "npt.NDArray[np.float64]") @@ -148,8 +141,8 @@ def test_mul_numpy_array(left: "pd.Series[str]") -> None: assert_type(s * left, Any) assert_type(d * left, "npt.NDArray[np.timedelta64]") - if PD_LTE_23: - check(assert_type(left.mul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.mul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.mul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.mul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -157,8 +150,8 @@ def test_mul_numpy_array(left: "pd.Series[str]") -> None: left.mul(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.mul(d) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] - if PD_LTE_23: - check(assert_type(left.rmul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.rmul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.rmul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.rmul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -176,10 +169,8 @@ def test_mul_pd_index(left: "pd.Series[str]") -> None: s = pd.Index([datetime(2025, 9, d) for d in (27, 28, 29)]) d = pd.Index([timedelta(seconds=s + 1) for s in range(3)]) - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x if TYPE_CHECKING_INVALID_USAGE: - check(assert_type(left * b, "pd.Series[str]"), pd.Series, str) + _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(left * i, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -188,7 +179,7 @@ def test_mul_pd_index(left: "pd.Series[str]") -> None: _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue] if TYPE_CHECKING_INVALID_USAGE: - check(assert_type(b * left, "pd.Series[str]"), pd.Series, str) + _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(i * left, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -197,7 +188,7 @@ def test_mul_pd_index(left: "pd.Series[str]") -> None: _15 = d * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] if TYPE_CHECKING_INVALID_USAGE: - check(assert_type(left.mul(b), "pd.Series[str]"), pd.Series, str) + left.mul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.mul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.mul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -205,8 +196,8 @@ def test_mul_pd_index(left: "pd.Series[str]") -> None: left.mul(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.mul(d) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] - if PD_LTE_23: - check(assert_type(left.rmul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.rmul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.rmul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.rmul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -224,10 +215,8 @@ def test_mul_pd_series(left: "pd.Series[str]") -> None: s = pd.Series([datetime(2025, 9, d) for d in (27, 28, 29)]) d = pd.Series([timedelta(seconds=s + 1) for s in range(3)]) - # pandas-dev/pandas#62595: we may want to support Series[str] * bool - # also in 3.x - if PD_LTE_23: - check(assert_type(left * b, "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(left * i, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -235,8 +224,8 @@ def test_mul_pd_series(left: "pd.Series[str]") -> None: _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(b * left, "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] check(assert_type(i * left, "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] @@ -244,8 +233,8 @@ def test_mul_pd_series(left: "pd.Series[str]") -> None: _14 = s * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] _15 = d * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue] - if PD_LTE_23: - check(assert_type(left.mul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.mul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.mul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.mul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] @@ -253,8 +242,8 @@ def test_mul_pd_series(left: "pd.Series[str]") -> None: left.mul(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] left.mul(d) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] - if PD_LTE_23: - check(assert_type(left.rmul(b), "pd.Series[str]"), pd.Series, str) + if TYPE_CHECKING_INVALID_USAGE: + left.rmul(b) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue] check(assert_type(left.rmul(i), "pd.Series[str]"), pd.Series, str) if TYPE_CHECKING_INVALID_USAGE: left.rmul(f) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]