1414)
1515
1616from tests import (
17- PD_LTE_23 ,
1817 TYPE_CHECKING_INVALID_USAGE ,
1918 check ,
2019)
@@ -32,19 +31,17 @@ def test_mul_py_scalar(left: "pd.Index[str]") -> None:
3231 b , i , f , c = True , 1 , 1.0 , 1j
3332 s , d = datetime (2025 , 9 , 27 ), timedelta (seconds = 1 )
3433
35- # pandas-dev/pandas#62595: we may want to support Series[str] * bool
36- # also in 3.x
37- if PD_LTE_23 :
38- check (assert_type (left * b , "pd.Index[str]" ), pd .Index , str )
34+ if TYPE_CHECKING_INVALID_USAGE :
35+ _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
3936 check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
4037 if TYPE_CHECKING_INVALID_USAGE :
4138 _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
4239 _03 = left * c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
4340 _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
4441 _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
4542
46- if PD_LTE_23 :
47- check ( assert_type ( b * left , "pd.Index[str]" ), pd . Index , str )
43+ if TYPE_CHECKING_INVALID_USAGE :
44+ _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
4845 check (assert_type (i * left , "pd.Index[str]" ), pd .Index , str )
4946 if TYPE_CHECKING_INVALID_USAGE :
5047 _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
@@ -59,19 +56,17 @@ def test_mul_py_sequence(left: "pd.Index[str]") -> None:
5956 s = [datetime (2025 , 9 , d ) for d in (27 , 28 , 29 )]
6057 d = [timedelta (seconds = s + 1 ) for s in range (3 )]
6158
62- # pandas-dev/pandas#62595: we may want to support Series[str] * bool
63- # also in 3.x
64- if PD_LTE_23 :
65- check (assert_type (left * b , "pd.Index[str]" ), pd .Index , str )
59+ if TYPE_CHECKING_INVALID_USAGE :
60+ _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
6661 check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
6762 if TYPE_CHECKING_INVALID_USAGE :
6863 _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
6964 _03 = left * c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
7065 _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
7166 _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
7267
73- if PD_LTE_23 :
74- check ( assert_type ( b * left , "pd.Index[str]" ), pd . Index , str )
68+ if TYPE_CHECKING_INVALID_USAGE :
69+ _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
7570 check (assert_type (i * left , "pd.Index[str]" ), pd .Index , str )
7671 if TYPE_CHECKING_INVALID_USAGE :
7772 _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
@@ -89,10 +84,8 @@ def test_mul_numpy_array(left: "pd.Index[str]") -> None:
8984 s = np .array ([np .datetime64 (f"2025-09-{ d } " ) for d in (27 , 28 , 29 )], np .datetime64 )
9085 d = np .array ([np .timedelta64 (s + 1 , "s" ) for s in range (3 )], np .timedelta64 )
9186
92- # pandas-dev/pandas#62595: we may want to support Series[str] * bool
93- # also in 3.x
94- if PD_LTE_23 :
95- check (assert_type (left * b , "pd.Index[str]" ), pd .Index , str )
87+ if TYPE_CHECKING_INVALID_USAGE :
88+ assert_type (left * b , Never )
9689 check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
9790 if TYPE_CHECKING_INVALID_USAGE :
9891 assert_type (left * f , Never )
@@ -103,8 +96,8 @@ def test_mul_numpy_array(left: "pd.Index[str]") -> None:
10396 # `numpy` typing gives the corresponding `ndarray`s in the static type
10497 # checking, where our `__rmul__` cannot override. At runtime, they return
10598 # `Index` with the correct element type.
106- if PD_LTE_23 :
107- check ( assert_type (b * left , "npt.NDArray[np.bool_]" ), pd . Index , str )
99+ if TYPE_CHECKING_INVALID_USAGE :
100+ assert_type (b * left , "npt.NDArray[np.bool_]" )
108101 check (assert_type (i * left , "npt.NDArray[np.int64]" ), pd .Index , str )
109102 if TYPE_CHECKING_INVALID_USAGE :
110103 assert_type (f * left , "npt.NDArray[np.float64]" )
@@ -122,19 +115,17 @@ def test_mul_pd_index(left: "pd.Index[str]") -> None:
122115 s = pd .Index ([datetime (2025 , 9 , d ) for d in (27 , 28 , 29 )])
123116 d = pd .Index ([timedelta (seconds = s + 1 ) for s in range (3 )])
124117
125- # pandas-dev/pandas#62595: we may want to support Series[str] * bool
126- # also in 3.x
127- if PD_LTE_23 :
128- check (assert_type (left * b , "pd.Index[str]" ), pd .Index , str )
118+ if TYPE_CHECKING_INVALID_USAGE :
119+ _00 = left * b # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
129120 check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
130121 if TYPE_CHECKING_INVALID_USAGE :
131122 _02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
132123 _03 = left * c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
133124 _04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
134125 _05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
135126
136- if PD_LTE_23 :
137- check ( assert_type ( b * left , "pd.Index[str]" ), pd . Index , str )
127+ if TYPE_CHECKING_INVALID_USAGE :
128+ _10 = b * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
138129 check (assert_type (i * left , "pd.Index[str]" ), pd .Index , str )
139130 if TYPE_CHECKING_INVALID_USAGE :
140131 _12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
0 commit comments