@@ -188,7 +188,6 @@ from pandas.core.dtypes.dtypes import CategoricalDtype
188
188
189
189
from pandas .plotting import PlotAccessor
190
190
191
- _T_NUM_NON_BOOL = TypeVar ("_T_NUM_NON_BOOL" , int , float , complex )
192
191
_T_INT = TypeVar ("_T_INT" , bound = int )
193
192
_T_COMPLEX = TypeVar ("_T_COMPLEX" , bound = complex )
194
193
@@ -2072,14 +2071,19 @@ class Series(IndexOpsMixin[S1], NDFrame):
2072
2071
@overload
2073
2072
def __sub__ (self , other : Series [Never ]) -> Series : ... # type: ignore[overload-overlap]
2074
2073
@overload
2074
+ def __sub__ (self : Series [bool ], other : bool | Sequence [bool ]) -> Never : ...
2075
+ @overload
2075
2076
def __sub__ (
2076
- self : Series [bool ],
2077
- other : _T_NUM_NON_BOOL | Sequence [_T_NUM_NON_BOOL ] | Series [_T_NUM_NON_BOOL ],
2078
- ) -> Series [_T_NUM_NON_BOOL ]: ...
2077
+ self : Series [bool ], other : _T_COMPLEX | Sequence [_T_COMPLEX ]
2078
+ ) -> Series [_T_COMPLEX ]: ...
2079
2079
@overload
2080
- def __sub__ (self : Series [bool ], other : np_ndarray_anyint ) -> Series [int ]: ...
2080
+ def __sub__ (
2081
+ self : Series [bool ], other : np_ndarray_anyint | Series [int ]
2082
+ ) -> Series [int ]: ...
2081
2083
@overload
2082
- def __sub__ (self : Series [bool ], other : np_ndarray_float ) -> Series [float ]: ...
2084
+ def __sub__ (
2085
+ self : Series [bool ], other : np_ndarray_float | Series [float ]
2086
+ ) -> Series [float ]: ...
2083
2087
@overload
2084
2088
def __sub__ (
2085
2089
self : Series [int ],
@@ -2097,8 +2101,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
2097
2101
def __sub__ (
2098
2102
self : Series [float ],
2099
2103
other : (
2100
- _T_INT
2101
- | Sequence [_T_INT ]
2104
+ int
2105
+ | Sequence [int ]
2102
2106
| np_ndarray_bool
2103
2107
| np_ndarray_anyint
2104
2108
| np_ndarray_float
@@ -2114,7 +2118,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
2114
2118
def __sub__ (
2115
2119
self : Series [complex ],
2116
2120
other : (
2117
- Sequence [_T_COMPLEX ]
2121
+ _T_COMPLEX
2122
+ | Sequence [_T_COMPLEX ]
2118
2123
| np_ndarray_bool
2119
2124
| np_ndarray_anyint
2120
2125
| np_ndarray_float
@@ -2123,7 +2128,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
2123
2128
) -> Series [complex ]: ...
2124
2129
@overload
2125
2130
def __sub__ (
2126
- self : Series [_T_COMPLEX ], other : np_ndarray_complex
2131
+ self : Series [_T_COMPLEX ], other : np_ndarray_complex | Series [ complex ]
2127
2132
) -> Series [complex ]: ...
2128
2133
@overload
2129
2134
def __sub__ (
@@ -2136,8 +2141,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
2136
2141
other : Timedelta | TimedeltaSeries | TimedeltaIndex | np .timedelta64 ,
2137
2142
) -> TimedeltaSeries : ...
2138
2143
@overload
2139
- def __sub__ (self , other : S1 | Series [S1 ]) -> Self : ...
2140
- @overload
2141
2144
def sub (
2142
2145
self : Series [Never ],
2143
2146
other : complex | _ListLike | Series ,
@@ -2148,20 +2151,36 @@ class Series(IndexOpsMixin[S1], NDFrame):
2148
2151
@overload
2149
2152
def sub (
2150
2153
self : Series [bool ],
2151
- other : _T_NUM_NON_BOOL | Sequence [_T_NUM_NON_BOOL ] | Series [ _T_NUM_NON_BOOL ],
2154
+ other : bool | Sequence [bool ],
2152
2155
level : Level | None = None ,
2153
2156
fill_value : float | None = None ,
2154
2157
axis : int = 0 ,
2155
- ) -> Series [ _T_NUM_NON_BOOL ] : ...
2158
+ ) -> Never : ...
2156
2159
@overload
2157
2160
def sub (
2158
2161
self : Series [bool ],
2159
- other : np_ndarray_anyint ,
2162
+ other : _T_COMPLEX | Sequence [_T_COMPLEX ],
2163
+ level : Level | None = None ,
2164
+ fill_value : float | None = None ,
2165
+ axis : int = 0 ,
2166
+ ) -> Series [_T_COMPLEX ]: ...
2167
+ @overload
2168
+ def sub (
2169
+ self : Series [bool ],
2170
+ other : np_ndarray_anyint | Series [int ],
2160
2171
level : Level | None = None ,
2161
2172
fill_value : float | None = None ,
2162
2173
axis : int = 0 ,
2163
2174
) -> Series [int ]: ...
2164
2175
@overload
2176
+ def sub (
2177
+ self : Series [bool ],
2178
+ other : np_ndarray_float | Series [float ],
2179
+ level : Level | None = None ,
2180
+ fill_value : float | None = None ,
2181
+ axis : int = 0 ,
2182
+ ) -> Series [float ]: ...
2183
+ @overload
2165
2184
def sub (
2166
2185
self : Series [int ],
2167
2186
other : (
@@ -2191,8 +2210,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
2191
2210
def sub (
2192
2211
self : Series [float ],
2193
2212
other : (
2194
- _T_INT
2195
- | Sequence [_T_INT ]
2213
+ int
2214
+ | Sequence [int ]
2196
2215
| np_ndarray_bool
2197
2216
| np_ndarray_anyint
2198
2217
| np_ndarray_float
@@ -2214,7 +2233,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
2214
2233
def sub (
2215
2234
self : Series [complex ],
2216
2235
other : (
2217
- Sequence [_T_COMPLEX ]
2236
+ _T_COMPLEX
2237
+ | Sequence [_T_COMPLEX ]
2218
2238
| np_ndarray_bool
2219
2239
| np_ndarray_anyint
2220
2240
| np_ndarray_float
@@ -2227,94 +2247,116 @@ class Series(IndexOpsMixin[S1], NDFrame):
2227
2247
@overload
2228
2248
def sub (
2229
2249
self : Series [_T_COMPLEX ],
2230
- other : np_ndarray_complex ,
2250
+ other : np_ndarray_complex | Series [ complex ] ,
2231
2251
level : Level | None = None ,
2232
2252
fill_value : float | None = None ,
2233
2253
axis : int = 0 ,
2234
2254
) -> Series [complex ]: ...
2235
2255
@overload
2236
- def sub (
2237
- self ,
2238
- other : S1 | Series [S1 ],
2239
- level : Level | None = None ,
2240
- fill_value : float | None = None ,
2241
- axis : int = 0 ,
2242
- ) -> Self : ...
2256
+ def __rsub__ (
2257
+ self : Series [Never ], other : complex | _ListLike | Series
2258
+ ) -> Series : ...
2243
2259
@overload
2244
- def __rsub__ (self : Series [Never ], other : complex | _ListLike ) -> Series : ...
2260
+ def __rsub__ (self , other : Series [Never ]) -> Series : ...
2261
+ @overload
2262
+ def __rsub__ (self : Series [bool ], other : bool | Sequence [bool ]) -> Never : ...
2263
+ @overload
2264
+ def __rsub__ (
2265
+ self : Series [bool ], other : _T_COMPLEX | Sequence [_T_COMPLEX ]
2266
+ ) -> Series [_T_COMPLEX ]: ...
2245
2267
@overload
2246
2268
def __rsub__ (
2247
- self : Series [bool ], other : _T_NUM_NON_BOOL | Sequence [ _T_NUM_NON_BOOL ]
2248
- ) -> Series [_T_NUM_NON_BOOL ]: ...
2269
+ self : Series [bool ], other : np_ndarray_anyint | Series [ int ]
2270
+ ) -> Series [int ]: ...
2249
2271
@overload
2250
- def __rsub__ (self : Series [bool ], other : np_ndarray_anyint ) -> Series [int ]: ...
2272
+ def __rsub__ (
2273
+ self : Series [bool ], other : np_ndarray_float | Series [float ]
2274
+ ) -> Series [float ]: ...
2251
2275
@overload
2252
2276
def __rsub__ (
2253
2277
self : Series [int ],
2254
2278
other : bool | Sequence [bool ] | np_ndarray_bool | np_ndarray_anyint ,
2255
2279
) -> Series [int ]: ...
2256
2280
@overload
2257
2281
def __rsub__ (
2258
- self : Series [int ], other : _T_COMPLEX | Sequence [_T_COMPLEX ]
2282
+ self : Series [int ], other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [ _T_COMPLEX ]
2259
2283
) -> Series [_T_COMPLEX ]: ...
2260
2284
@overload
2261
2285
def __rsub__ (self : Series [_T_INT ], other : np_ndarray_float ) -> Series [float ]: ...
2262
2286
@overload
2263
2287
def __rsub__ (
2264
2288
self : Series [float ],
2265
2289
other : (
2266
- _T_INT
2267
- | Sequence [_T_INT ]
2290
+ int
2291
+ | Sequence [int ]
2268
2292
| np_ndarray_bool
2269
2293
| np_ndarray_anyint
2270
2294
| np_ndarray_float
2295
+ | Series [_T_INT ]
2271
2296
),
2272
2297
) -> Series [float ]: ...
2273
2298
@overload
2274
2299
def __rsub__ (
2275
- self : Series [float ], other : _T_COMPLEX | Sequence [_T_COMPLEX ]
2300
+ self : Series [float ],
2301
+ other : _T_COMPLEX | Sequence [_T_COMPLEX ] | Series [_T_COMPLEX ],
2276
2302
) -> Series [_T_COMPLEX ]: ...
2277
2303
@overload
2278
2304
def __rsub__ (
2279
2305
self : Series [complex ],
2280
2306
other : (
2281
- Sequence [_T_COMPLEX ]
2307
+ _T_COMPLEX
2308
+ | Sequence [_T_COMPLEX ]
2282
2309
| np_ndarray_bool
2283
2310
| np_ndarray_anyint
2284
2311
| np_ndarray_float
2312
+ | Series [_T_COMPLEX ]
2285
2313
),
2286
2314
) -> Series [complex ]: ...
2287
2315
@overload
2288
2316
def __rsub__ (
2289
- self : Series [_T_COMPLEX ], other : np_ndarray_complex
2317
+ self : Series [_T_COMPLEX ], other : np_ndarray_complex | Series [ complex ]
2290
2318
) -> Series [complex ]: ...
2291
2319
@overload
2292
- def __rsub__ (self , other : S1 ) -> Self : ...
2293
- @overload
2294
2320
def rsub (
2295
2321
self : Series [Never ],
2296
- other : Scalar | _ListLike | Series ,
2322
+ other : complex | _ListLike | Series ,
2297
2323
level : Level | None = None ,
2298
2324
fill_value : float | None = None ,
2299
2325
axis : int = 0 ,
2300
2326
) -> Series : ...
2301
2327
@overload
2302
2328
def rsub (
2303
2329
self : Series [bool ],
2304
- other : _T_NUM_NON_BOOL | Sequence [_T_NUM_NON_BOOL ] | Series [ _T_NUM_NON_BOOL ],
2330
+ other : bool | Sequence [bool ],
2305
2331
level : Level | None = None ,
2306
2332
fill_value : float | None = None ,
2307
2333
axis : int = 0 ,
2308
- ) -> Series [ _T_NUM_NON_BOOL ] : ...
2334
+ ) -> Never : ...
2309
2335
@overload
2310
2336
def rsub (
2311
2337
self : Series [bool ],
2312
- other : np_ndarray_anyint ,
2338
+ other : _T_COMPLEX | Sequence [_T_COMPLEX ],
2339
+ level : Level | None = None ,
2340
+ fill_value : float | None = None ,
2341
+ axis : int = 0 ,
2342
+ ) -> Series [_T_COMPLEX ]: ...
2343
+ @overload
2344
+ def rsub (
2345
+ self : Series [bool ],
2346
+ other : np_ndarray_anyint | Series [int ],
2313
2347
level : Level | None = None ,
2314
2348
fill_value : float | None = None ,
2315
2349
axis : int = 0 ,
2316
2350
) -> Series [int ]: ...
2317
2351
@overload
2352
+ def rsub (
2353
+ self : Series [bool ],
2354
+ other : np_ndarray_float | Series [float ],
2355
+ level : Level | None = None ,
2356
+ fill_value : float | None = None ,
2357
+ axis : int = 0 ,
2358
+ ) -> Series [float ]: ...
2359
+ @overload
2318
2360
def rsub (
2319
2361
self : Series [int ],
2320
2362
other : (
@@ -2344,8 +2386,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
2344
2386
def rsub (
2345
2387
self : Series [float ],
2346
2388
other : (
2347
- _T_INT
2348
- | Sequence [_T_INT ]
2389
+ int
2390
+ | Sequence [int ]
2349
2391
| np_ndarray_bool
2350
2392
| np_ndarray_anyint
2351
2393
| np_ndarray_float
@@ -2367,7 +2409,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
2367
2409
def rsub (
2368
2410
self : Series [complex ],
2369
2411
other : (
2370
- Sequence [_T_COMPLEX ]
2412
+ _T_COMPLEX
2413
+ | Sequence [_T_COMPLEX ]
2371
2414
| np_ndarray_bool
2372
2415
| np_ndarray_anyint
2373
2416
| np_ndarray_float
@@ -2380,20 +2423,12 @@ class Series(IndexOpsMixin[S1], NDFrame):
2380
2423
@overload
2381
2424
def rsub (
2382
2425
self : Series [_T_COMPLEX ],
2383
- other : np_ndarray_complex ,
2426
+ other : np_ndarray_complex | Series [ complex ] ,
2384
2427
level : Level | None = None ,
2385
2428
fill_value : float | None = None ,
2386
2429
axis : int = 0 ,
2387
2430
) -> Series [complex ]: ...
2388
2431
@overload
2389
- def rsub (
2390
- self ,
2391
- other : S1 | Series [S1 ],
2392
- level : Level | None = None ,
2393
- fill_value : float | None = None ,
2394
- axis : int = 0 ,
2395
- ) -> Self : ...
2396
- @overload
2397
2432
def __truediv__ (
2398
2433
self : Series [Never ], other : complex | _ListLike | Series
2399
2434
) -> Series : ...
@@ -3248,7 +3283,7 @@ class TimestampSeries(Series[Timestamp]):
3248
3283
self , other : Timestamp | datetime | TimestampSeries
3249
3284
) -> TimedeltaSeries : ...
3250
3285
@overload
3251
- def __sub__ ( # pyright: ignore[reportIncompatibleMethodOverride]
3286
+ def __sub__ (
3252
3287
self ,
3253
3288
other : (
3254
3289
timedelta | TimedeltaSeries | TimedeltaIndex | np .timedelta64 | BaseOffset
0 commit comments