@@ -263,17 +263,7 @@ from ._typing import (
263
263
_TD64Like_co ,
264
264
_VoidDTypeLike ,
265
265
)
266
- from ._typing ._callable import (
267
- _BoolDivMod ,
268
- _BoolMod ,
269
- _BoolOp ,
270
- _BoolSub ,
271
- _BoolTrueDiv ,
272
- _ComparisonOpGE ,
273
- _ComparisonOpGT ,
274
- _ComparisonOpLE ,
275
- _ComparisonOpLT ,
276
- )
266
+ from ._typing ._callable import _ComparisonOpGE , _ComparisonOpGT , _ComparisonOpLE , _ComparisonOpLT
277
267
from ._typing ._char_codes import (
278
268
_BoolCodes ,
279
269
_BytesCodes ,
@@ -594,6 +584,7 @@ _1NShapeT = TypeVar("_1NShapeT", bound=tuple[L[1], Unpack[tuple[L[1], ...]]]) #
594
584
_ScalarT = TypeVar ("_ScalarT" , bound = generic )
595
585
_ScalarT_co = TypeVar ("_ScalarT_co" , bound = generic , covariant = True )
596
586
_NumberT = TypeVar ("_NumberT" , bound = number )
587
+ _InexactT = TypeVar ("_InexactT" , bound = inexact )
597
588
_RealNumberT = TypeVar ("_RealNumberT" , bound = floating | integer )
598
589
_IntegerT = TypeVar ("_IntegerT" , bound = integer )
599
590
_SignedIntegerT = TypeVar ("_SignedIntegerT" , bound = signedinteger )
@@ -4209,28 +4200,118 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
4209
4200
@overload
4210
4201
def __int__ (self : bool_ [py_bool ], / ) -> L [0 , 1 ]: ...
4211
4202
4212
- __lt__ : _ComparisonOpLT [_NumberLike_co , _ArrayLikeNumber_co ]
4213
- __le__ : _ComparisonOpLE [_NumberLike_co , _ArrayLikeNumber_co ]
4214
- __gt__ : _ComparisonOpGT [_NumberLike_co , _ArrayLikeNumber_co ]
4215
- __ge__ : _ComparisonOpGE [_NumberLike_co , _ArrayLikeNumber_co ]
4203
+ #
4204
+ def __abs__ (self , / ) -> Self : ...
4205
+
4206
+ #
4207
+ @overload
4208
+ def __add__ (self , x : _NumberT , / ) -> _NumberT : ...
4209
+ @overload
4210
+ def __add__ (self , x : py_bool | bool_ , / ) -> bool_ : ...
4211
+ @overload
4212
+ def __add__ (self , x : int , / ) -> intp | bool_ : ...
4213
+ @overload
4214
+ def __add__ (self , x : float , / ) -> float64 | intp | bool_ : ...
4215
+ @overload
4216
+ def __add__ (self , x : complex , / ) -> complex128 | float64 | intp | bool_ : ...
4217
+
4218
+ #
4219
+ @overload
4220
+ def __radd__ (self , x : _NumberT , / ) -> _NumberT : ...
4221
+ @overload
4222
+ def __radd__ (self , x : py_bool , / ) -> bool_ : ...
4223
+ @overload
4224
+ def __radd__ (self , x : int , / ) -> intp | bool_ : ...
4225
+ @overload
4226
+ def __radd__ (self , x : float , / ) -> float64 | intp | bool_ : ...
4227
+ @overload
4228
+ def __radd__ (self , x : complex , / ) -> complex128 | float64 | intp | bool_ : ...
4229
+
4230
+ #
4231
+ @overload
4232
+ def __mul__ (self , x : _NumberT , / ) -> _NumberT : ...
4233
+ @overload
4234
+ def __mul__ (self , x : py_bool | bool_ , / ) -> bool_ : ...
4235
+ @overload
4236
+ def __mul__ (self , x : int , / ) -> intp | bool_ : ...
4237
+ @overload
4238
+ def __mul__ (self , x : float , / ) -> float64 | intp | bool_ : ...
4239
+ @overload
4240
+ def __mul__ (self , x : complex , / ) -> complex128 | float64 | intp | bool_ : ...
4241
+
4242
+ #
4243
+ @overload
4244
+ def __rmul__ (self , x : _NumberT , / ) -> _NumberT : ...
4245
+ @overload
4246
+ def __rmul__ (self , x : py_bool , / ) -> bool_ : ...
4247
+ @overload
4248
+ def __rmul__ (self , x : int , / ) -> intp | bool_ : ...
4249
+ @overload
4250
+ def __rmul__ (self , x : float , / ) -> float64 | intp | bool_ : ...
4251
+ @overload
4252
+ def __rmul__ (self , x : complex , / ) -> complex128 | float64 | intp | bool_ : ...
4253
+
4254
+ #
4255
+ @overload
4256
+ def __sub__ (self , x : _NumberT , / ) -> _NumberT : ...
4257
+ @overload
4258
+ def __sub__ (self , x : int , / ) -> intp : ...
4259
+ @overload
4260
+ def __sub__ (self , x : float , / ) -> float64 | intp : ...
4261
+ @overload
4262
+ def __sub__ (self , x : complex , / ) -> complex128 | float64 | intp : ...
4263
+
4264
+ #
4265
+ @overload
4266
+ def __rsub__ (self , x : _NumberT , / ) -> _NumberT : ...
4267
+ @overload
4268
+ def __rsub__ (self , x : int , / ) -> intp : ...
4269
+ @overload
4270
+ def __rsub__ (self , x : float , / ) -> float64 | intp : ...
4271
+ @overload
4272
+ def __rsub__ (self , x : complex , / ) -> complex128 | float64 | intp : ...
4273
+
4274
+ #
4275
+ @overload
4276
+ def __truediv__ (self , x : _InexactT , / ) -> _InexactT : ...
4277
+ @overload
4278
+ def __truediv__ (self , x : float | integer | bool_ , / ) -> float64 : ...
4279
+ @overload
4280
+ def __truediv__ (self , x : float | complex , / ) -> complex128 | float64 : ...
4216
4281
4217
- def __abs__ (self ) -> Self : ...
4282
+ #
4283
+ @overload
4284
+ def __rtruediv__ (self , x : _InexactT , / ) -> _InexactT : ...
4285
+ @overload
4286
+ def __rtruediv__ (self , x : float | integer , / ) -> float64 : ...
4287
+ @overload
4288
+ def __rtruediv__ (self , x : float | complex , / ) -> complex128 | float64 : ...
4218
4289
4219
- __add__ : _BoolOp [bool_ ]
4220
- __radd__ : _BoolOp [bool_ ]
4221
- __mul__ : _BoolOp [bool_ ]
4222
- __rmul__ : _BoolOp [bool_ ]
4223
- __sub__ : _BoolSub
4224
- __rsub__ : _BoolSub
4225
- __truediv__ : _BoolTrueDiv
4226
- __rtruediv__ : _BoolTrueDiv
4227
- __floordiv__ : _BoolOp [int8 ]
4228
- __rfloordiv__ : _BoolOp [int8 ]
4290
+ #
4291
+ @overload
4292
+ def __floordiv__ (self , x : _RealNumberT , / ) -> _RealNumberT : ...
4293
+ @overload
4294
+ def __floordiv__ (self , x : py_bool | bool_ , / ) -> int8 : ...
4295
+ @overload
4296
+ def __floordiv__ (self , x : int , / ) -> intp | int8 : ...
4297
+ @overload
4298
+ def __floordiv__ (self , x : float , / ) -> float64 | intp | int8 : ...
4299
+
4300
+ #
4301
+ @overload
4302
+ def __rfloordiv__ (self , x : _RealNumberT , / ) -> _RealNumberT : ...
4303
+ @overload
4304
+ def __rfloordiv__ (self , x : py_bool , / ) -> int8 : ...
4305
+ @overload
4306
+ def __rfloordiv__ (self , x : int , / ) -> intp | int8 : ...
4307
+ @overload
4308
+ def __rfloordiv__ (self , x : float , / ) -> float64 | intp | int8 : ...
4229
4309
4310
+ #
4230
4311
@overload
4231
4312
def __pow__ (self , x : _NumberT , mod : None = None , / ) -> _NumberT : ...
4232
4313
@overload
4233
- def __pow__ (self , x : bool_ | py_bool , mod : None = None , / ) -> int8 : ...
4314
+ def __pow__ (self , x : py_bool | bool_ , mod : None = None , / ) -> int8 : ...
4234
4315
@overload
4235
4316
def __pow__ (self , x : int , mod : None = None , / ) -> intp | int8 : ...
4236
4317
@overload
@@ -4242,35 +4323,87 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
4242
4323
@overload
4243
4324
def __rpow__ (self , x : _NumberT , mod : None = None , / ) -> _NumberT : ...
4244
4325
@overload
4245
- def __rpow__ (self , x : bool_ | py_bool , mod : None = None , / ) -> int8 : ...
4326
+ def __rpow__ (self , x : py_bool , mod : None = None , / ) -> int8 : ...
4246
4327
@overload
4247
4328
def __rpow__ (self , x : int , mod : None = None , / ) -> intp | int8 : ...
4248
4329
@overload
4249
4330
def __rpow__ (self , x : float , mod : None = None , / ) -> float64 | intp | int8 : ...
4250
4331
@overload
4251
4332
def __rpow__ (self , x : complex , mod : None = None , / ) -> complex128 | float64 | intp | int8 : ...
4252
4333
4253
- __mod__ : _BoolMod
4254
- __rmod__ : _BoolMod
4255
- __divmod__ : _BoolDivMod
4256
- __rdivmod__ : _BoolDivMod
4334
+ #
4335
+ @overload
4336
+ def __mod__ (self , x : _RealNumberT , / ) -> _RealNumberT : ...
4337
+ @overload
4338
+ def __mod__ (self , x : py_bool | bool_ , / ) -> int8 : ...
4339
+ @overload
4340
+ def __mod__ (self , x : int , / ) -> intp | int8 : ...
4341
+ @overload
4342
+ def __mod__ (self , x : float , / ) -> float64 | intp | int8 : ...
4343
+
4344
+ #
4345
+ @overload
4346
+ def __rmod__ (self , x : _RealNumberT , / ) -> _RealNumberT : ...
4347
+ @overload
4348
+ def __rmod__ (self , x : py_bool , / ) -> int8 : ...
4349
+ @overload
4350
+ def __rmod__ (self , x : int , / ) -> intp | int8 : ...
4351
+ @overload
4352
+ def __rmod__ (self , x : float , / ) -> float64 | intp | int8 : ...
4353
+
4354
+ #
4355
+ @overload
4356
+ def __divmod__ (self , x : _RealNumberT , / ) -> _2Tuple [_RealNumberT ]: ...
4357
+ @overload
4358
+ def __divmod__ (self , x : py_bool | bool_ , / ) -> _2Tuple [int8 ]: ...
4359
+ @overload
4360
+ def __divmod__ (self , x : int , / ) -> _2Tuple [intp ] | _2Tuple [int8 ]: ...
4361
+ @overload
4362
+ def __divmod__ (self , x : float , / ) -> _2Tuple [float64 ] | _2Tuple [intp ] | _2Tuple [int8 ]: ...
4257
4363
4364
+ #
4365
+ @overload
4366
+ def __rdivmod__ (self , x : _RealNumberT , / ) -> _2Tuple [_RealNumberT ]: ...
4367
+ @overload
4368
+ def __rdivmod__ (self , x : py_bool , / ) -> _2Tuple [int8 ]: ...
4369
+ @overload
4370
+ def __rdivmod__ (self , x : int , / ) -> _2Tuple [intp ] | _2Tuple [int8 ]: ...
4371
+ @overload
4372
+ def __rdivmod__ (self , x : float , / ) -> _2Tuple [float64 ] | _2Tuple [intp ] | _2Tuple [int8 ]: ...
4373
+
4374
+ #
4258
4375
@overload
4259
4376
def __lshift__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4260
4377
@overload
4261
4378
def __lshift__ (self , x : py_bool | bool_ , / ) -> int8 : ...
4262
4379
@overload
4263
- def __lshift__ (self , x : int , / ) -> int8 | intp : ...
4264
- __rlshift__ = __lshift__
4380
+ def __lshift__ (self , x : int , / ) -> intp | int8 : ...
4265
4381
4382
+ #
4383
+ @overload
4384
+ def __rlshift__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4385
+ @overload
4386
+ def __rlshift__ (self , x : py_bool | bool_ , / ) -> int8 : ...
4387
+ @overload
4388
+ def __rlshift__ (self , x : int , / ) -> intp | int8 : ...
4389
+
4390
+ #
4266
4391
@overload
4267
4392
def __rshift__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4268
4393
@overload
4269
4394
def __rshift__ (self , x : py_bool | bool_ , / ) -> int8 : ...
4270
4395
@overload
4271
- def __rshift__ (self , x : int , / ) -> int8 | intp : ...
4272
- __rrshift__ = __rshift__
4396
+ def __rshift__ (self , x : int , / ) -> intp | int8 : ...
4397
+
4398
+ #
4399
+ @overload
4400
+ def __rrshift__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4401
+ @overload
4402
+ def __rrshift__ (self , x : py_bool | bool_ , / ) -> int8 : ...
4403
+ @overload
4404
+ def __rrshift__ (self , x : int , / ) -> intp | int8 : ...
4273
4405
4406
+ #
4274
4407
@overload
4275
4408
def __invert__ (self : bool_ [L [False ]], / ) -> bool_ [L [True ]]: ...
4276
4409
@overload
@@ -4290,9 +4423,23 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
4290
4423
@overload
4291
4424
def __and__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4292
4425
@overload
4293
- def __and__ (self , x : int , / ) -> bool_ | intp : ...
4294
- __rand__ = __and__
4426
+ def __and__ (self , x : int , / ) -> intp | bool_ : ...
4295
4427
4428
+ #
4429
+ @overload
4430
+ def __rand__ (self : bool_ [L [False ]], x : py_bool , / ) -> bool_ [L [False ]]: ...
4431
+ @overload
4432
+ def __rand__ (self , x : L [False ], / ) -> bool_ [L [False ]]: ...
4433
+ @overload
4434
+ def __rand__ (self , x : L [True ], / ) -> Self : ...
4435
+ @overload
4436
+ def __rand__ (self , x : py_bool , / ) -> bool_ : ...
4437
+ @overload
4438
+ def __rand__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4439
+ @overload
4440
+ def __rand__ (self , x : int , / ) -> intp | bool_ : ...
4441
+
4442
+ #
4296
4443
@overload
4297
4444
def __xor__ (self : bool_ [L [False ]], x : _BoolItemT | bool_ [_BoolItemT ], / ) -> bool_ [_BoolItemT ]: ...
4298
4445
@overload
@@ -4304,9 +4451,23 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
4304
4451
@overload
4305
4452
def __xor__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4306
4453
@overload
4307
- def __xor__ (self , x : int , / ) -> bool_ | intp : ...
4308
- __rxor__ = __xor__
4454
+ def __xor__ (self , x : int , / ) -> intp | bool_ : ...
4455
+
4456
+ #
4457
+ @overload
4458
+ def __rxor__ (self : bool_ [L [False ]], x : _BoolItemT , / ) -> bool_ [_BoolItemT ]: ...
4459
+ @overload
4460
+ def __rxor__ (self : bool_ [L [True ]], x : L [True ], / ) -> bool_ [L [False ]]: ...
4461
+ @overload
4462
+ def __rxor__ (self , x : L [False ], / ) -> Self : ...
4463
+ @overload
4464
+ def __rxor__ (self , x : py_bool , / ) -> bool_ : ...
4465
+ @overload
4466
+ def __rxor__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4467
+ @overload
4468
+ def __rxor__ (self , x : int , / ) -> intp | bool_ : ...
4309
4469
4470
+ #
4310
4471
@overload
4311
4472
def __or__ (self : bool_ [L [True ]], x : py_bool | bool_ , / ) -> bool_ [L [True ]]: ...
4312
4473
@overload
@@ -4318,8 +4479,27 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
4318
4479
@overload
4319
4480
def __or__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4320
4481
@overload
4321
- def __or__ (self , x : int , / ) -> bool_ | intp : ...
4322
- __ror__ = __or__
4482
+ def __or__ (self , x : int , / ) -> intp | bool_ : ...
4483
+
4484
+ #
4485
+ @overload
4486
+ def __ror__ (self : bool_ [L [True ]], x : py_bool , / ) -> bool_ [L [True ]]: ...
4487
+ @overload
4488
+ def __ror__ (self , x : L [False ], / ) -> Self : ...
4489
+ @overload
4490
+ def __ror__ (self , x : L [True ], / ) -> bool_ [L [True ]]: ...
4491
+ @overload
4492
+ def __ror__ (self , x : py_bool , / ) -> bool_ : ...
4493
+ @overload
4494
+ def __ror__ (self , x : _IntegerT , / ) -> _IntegerT : ...
4495
+ @overload
4496
+ def __ror__ (self , x : int , / ) -> intp | bool_ : ...
4497
+
4498
+ #
4499
+ __lt__ : _ComparisonOpLT [_NumberLike_co , _ArrayLikeNumber_co ]
4500
+ __le__ : _ComparisonOpLE [_NumberLike_co , _ArrayLikeNumber_co ]
4501
+ __gt__ : _ComparisonOpGT [_NumberLike_co , _ArrayLikeNumber_co ]
4502
+ __ge__ : _ComparisonOpGE [_NumberLike_co , _ArrayLikeNumber_co ]
4323
4503
4324
4504
# NOTE: The `object_` constructor returns the passed object, so instances with type
4325
4505
# `object_` cannot exists (at runtime).
0 commit comments