14
14
)
15
15
16
16
from tests import (
17
- PD_LTE_23 ,
18
17
TYPE_CHECKING_INVALID_USAGE ,
19
18
check ,
20
19
)
@@ -32,19 +31,17 @@ def test_mul_py_scalar(left: "pd.Index[str]") -> None:
32
31
b , i , f , c = True , 1 , 1.0 , 1j
33
32
s , d = datetime (2025 , 9 , 27 ), timedelta (seconds = 1 )
34
33
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]
39
36
check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
40
37
if TYPE_CHECKING_INVALID_USAGE :
41
38
_02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
42
39
_03 = left * c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
43
40
_04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
44
41
_05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
45
42
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]
48
45
check (assert_type (i * left , "pd.Index[str]" ), pd .Index , str )
49
46
if TYPE_CHECKING_INVALID_USAGE :
50
47
_12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
@@ -59,19 +56,17 @@ def test_mul_py_sequence(left: "pd.Index[str]") -> None:
59
56
s = [datetime (2025 , 9 , d ) for d in (27 , 28 , 29 )]
60
57
d = [timedelta (seconds = s + 1 ) for s in range (3 )]
61
58
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]
66
61
check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
67
62
if TYPE_CHECKING_INVALID_USAGE :
68
63
_02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
69
64
_03 = left * c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
70
65
_04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
71
66
_05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
72
67
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]
75
70
check (assert_type (i * left , "pd.Index[str]" ), pd .Index , str )
76
71
if TYPE_CHECKING_INVALID_USAGE :
77
72
_12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
@@ -89,10 +84,8 @@ def test_mul_numpy_array(left: "pd.Index[str]") -> None:
89
84
s = np .array ([np .datetime64 (f"2025-09-{ d } " ) for d in (27 , 28 , 29 )], np .datetime64 )
90
85
d = np .array ([np .timedelta64 (s + 1 , "s" ) for s in range (3 )], np .timedelta64 )
91
86
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 )
96
89
check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
97
90
if TYPE_CHECKING_INVALID_USAGE :
98
91
assert_type (left * f , Never )
@@ -103,8 +96,8 @@ def test_mul_numpy_array(left: "pd.Index[str]") -> None:
103
96
# `numpy` typing gives the corresponding `ndarray`s in the static type
104
97
# checking, where our `__rmul__` cannot override. At runtime, they return
105
98
# `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_]" )
108
101
check (assert_type (i * left , "npt.NDArray[np.int64]" ), pd .Index , str )
109
102
if TYPE_CHECKING_INVALID_USAGE :
110
103
assert_type (f * left , "npt.NDArray[np.float64]" )
@@ -122,19 +115,17 @@ def test_mul_pd_index(left: "pd.Index[str]") -> None:
122
115
s = pd .Index ([datetime (2025 , 9 , d ) for d in (27 , 28 , 29 )])
123
116
d = pd .Index ([timedelta (seconds = s + 1 ) for s in range (3 )])
124
117
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]
129
120
check (assert_type (left * i , "pd.Index[str]" ), pd .Index , str )
130
121
if TYPE_CHECKING_INVALID_USAGE :
131
122
_02 = left * f # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
132
123
_03 = left * c # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
133
124
_04 = left * s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
134
125
_05 = left * d # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
135
126
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]
138
129
check (assert_type (i * left , "pd.Index[str]" ), pd .Index , str )
139
130
if TYPE_CHECKING_INVALID_USAGE :
140
131
_12 = f * left # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
0 commit comments