Skip to content

Commit 67da6f4

Browse files
committed
🐴 work around the remaining mypy issues
1 parent 153cc50 commit 67da6f4

File tree

2 files changed

+42
-51
lines changed

2 files changed

+42
-51
lines changed

src/numpy-stubs/__init__.pyi

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ _BitT2 = TypeVar("_BitT2", bound=NBitBase, default=_BitT1) # pyright: ignore[re
666666

667667
_ItemT_co = TypeVar("_ItemT_co", default=Any, covariant=True)
668668
_BoolItemT_co = TypeVar("_BoolItemT_co", bound=py_bool, default=py_bool, covariant=True)
669+
_NumberItemT = TypeVar("_NumberItemT", bound=complex)
669670
_NumberItemT_co = TypeVar("_NumberItemT_co", bound=complex, default=Any, covariant=True)
670671
_InexactItemT_co = TypeVar("_InexactItemT_co", bound=complex, default=Any, covariant=True)
671672
_FlexItemT_co = TypeVar(
@@ -2212,9 +2213,9 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
22122213

22132214
#
22142215
@overload
2215-
def __sub__(self: NDArray[_NumericT], x: _nt.Casts[_NumericT], /) -> NDArray[_NumericT]: ... # type: ignore[overload-overlap]
2216+
def __sub__(self: NDArray[_NumericT], x: _nt.Casts[_NumericT], /) -> NDArray[_NumericT]: ...
22162217
@overload
2217-
def __sub__(self: NDArray[_SelfScalarT], x: _nt.CastsWith[_SelfScalarT, _ScalarT], /) -> NDArray[_ScalarT]: ... # type: ignore[overload-overlap]
2218+
def __sub__(self: NDArray[_CoNumberT], x: _nt.CastsWith[_CoNumberT, _ScalarT], /) -> NDArray[_ScalarT]: ...
22182219
@overload
22192220
def __sub__(self: _nt.CastsWithBuiltin[_T, _NumericT], x: _nt.SequenceND[_T], /) -> NDArray[_NumericT]: ...
22202221
@overload
@@ -2228,15 +2229,17 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
22282229
@overload
22292230
def __sub__(self: NDArray[datetime64], x: _nt.CoTimeDelta_nd, /) -> NDArray[datetime64]: ...
22302231
@overload
2231-
def __sub__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ... # type: ignore[overload-cannot-match]
2232+
def __sub__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ...
22322233
@overload
2233-
def __sub__(self: NDArray[generic[_T]], x: _nt.Sequence1ND[_nt.op.CanRSub[_T]], /) -> NDArray[Incomplete]: ...
2234+
def __sub__(
2235+
self: NDArray[generic[_NumberItemT]], x: _nt.Sequence1ND[_nt.op.CanRSub[_NumberItemT]], /
2236+
) -> NDArray[Incomplete]: ...
22342237

22352238
#
22362239
@overload
2237-
def __rsub__(self: NDArray[_NumericT], x: _nt.Casts[_NumericT], /) -> NDArray[_NumericT]: ... # type: ignore[overload-overlap]
2240+
def __rsub__(self: NDArray[_NumericT], x: _nt.Casts[_NumericT], /) -> NDArray[_NumericT]: ...
22382241
@overload
2239-
def __rsub__(self: NDArray[_SelfScalarT], x: _nt.CastsWith[_SelfScalarT, _ScalarT], /) -> NDArray[_ScalarT]: ... # type: ignore[overload-overlap]
2242+
def __rsub__(self: NDArray[_CoNumberT], x: _nt.CastsWith[_CoNumberT, _ScalarT], /) -> NDArray[_ScalarT]: ...
22402243
@overload
22412244
def __rsub__(self: _nt.CastsWithBuiltin[_T, _NumericT], x: _nt.SequenceND[_T], /) -> NDArray[_NumericT]: ...
22422245
@overload
@@ -2250,16 +2253,16 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
22502253
@overload
22512254
def __rsub__(self: NDArray[_nt.co_timedelta], x: _nt.ToDateTime_nd, /) -> NDArray[datetime64]: ...
22522255
@overload
2253-
def __rsub__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ... # type: ignore[overload-cannot-match]
2256+
def __rsub__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ...
22542257
@overload
2255-
def __rsub__(self: NDArray[generic[_T]], x: _nt.Sequence1ND[_nt.op.CanSub[_T]], /) -> NDArray[Incomplete]: ...
2258+
def __rsub__(
2259+
self: NDArray[generic[_NumberItemT]], x: _nt.Sequence1ND[_nt.op.CanSub[_NumberItemT]], /
2260+
) -> NDArray[Incomplete]: ...
22562261

22572262
#
22582263
@overload # type: ignore[misc]
22592264
def __isub__(self: NDArray[_ScalarT], x: _nt.Casts[_ScalarT], /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
22602265
@overload
2261-
def __isub__(self: NDArray[bool_], x: _nt.SequenceND[bool], /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
2262-
@overload
22632266
def __isub__(self: NDArray[number], x: _nt.SequenceND[int], /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
22642267
@overload
22652268
def __isub__(self: NDArray[inexact], x: _nt.SequenceND[float], /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@@ -2271,7 +2274,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
22712274
def __isub__(self: NDArray[object_], x: object, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
22722275
@overload
22732276
def __isub__(
2274-
self: NDArray[generic[_T]], x: _nt.Sequence1ND[_nt.op.CanRSub[_T, _T]], /
2277+
self: NDArray[generic[_NumberItemT]], x: _nt.Sequence1ND[_nt.op.CanRSub[_T, _T]], /
22752278
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
22762279

22772280
#
@@ -2410,18 +2413,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
24102413
@overload
24112414
def __pow__(self: NDArray[_NumberT], x: _nt.Casts[_NumberT], k: None = None, /) -> NDArray[_NumberT]: ...
24122415
@overload
2413-
def __pow__(
2414-
self: NDArray[_CoNumberT], x: _nt.CastsWith[_CoNumberT, _ScalarT], k: None = None, /
2415-
) -> NDArray[_ScalarT]: ...
2416-
@overload
2417-
def __pow__(
2418-
self: _nt.CastsWithBuiltin[_T, _NumberT], x: _nt.SequenceND[_T], k: None = None, /
2419-
) -> NDArray[_NumberT]: ...
2416+
def __pow__(self: NDArray[bool_], x: _nt.ToBool_nd, k: None = None, /) -> NDArray[int8]: ...
24202417
@overload
24212418
def __pow__(
2422-
self: _nt.CastsWithInt[_ScalarT], x: _nt.SequenceND[_nt.JustInt], k: None = None, /
2419+
self: NDArray[_NumberT], x: _nt.CastsWith[_NumberT, _ScalarT], k: None = None, /
24232420
) -> NDArray[_ScalarT]: ...
24242421
@overload
2422+
def __pow__(self: _nt.CastsWithInt[_NumberT], x: _nt.SequenceND[int], k: None = None, /) -> NDArray[_NumberT]: ...
2423+
@overload
24252424
def __pow__(
24262425
self: _nt.CastsWithFloat[_ScalarT], x: _nt.SequenceND[_nt.JustFloat], k: None = None, /
24272426
) -> NDArray[_ScalarT]: ...
@@ -2430,26 +2429,20 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
24302429
self: _nt.CastsWithComplex[_ScalarT], x: _nt.SequenceND[_nt.JustComplex], k: None = None, /
24312430
) -> NDArray[_ScalarT]: ...
24322431
@overload
2433-
def __pow__(self: NDArray[bool_], x: _nt.ToBool_nd, k: None = None, /) -> NDArray[int8]: ...
2434-
@overload
24352432
def __pow__(self: NDArray[object_], x: object, k: None = None, /) -> NDArray[object_]: ...
24362433

24372434
#
24382435
@overload
24392436
def __rpow__(self: NDArray[_NumberT], x: _nt.Casts[_NumberT], k: None = None, /) -> NDArray[_NumberT]: ...
24402437
@overload
2441-
def __rpow__(
2442-
self: NDArray[_CoNumberT], x: _nt.CastsWith[_CoNumberT, _ScalarT], k: None = None, /
2443-
) -> NDArray[_ScalarT]: ...
2444-
@overload
2445-
def __rpow__(
2446-
self: _nt.CastsWithBuiltin[_T, _NumberT], x: _nt.SequenceND[_T], k: None = None, /
2447-
) -> NDArray[_NumberT]: ...
2438+
def __rpow__(self: NDArray[bool_], x: _nt.ToBool_nd, k: None = None, /) -> NDArray[int8]: ...
24482439
@overload
24492440
def __rpow__(
2450-
self: _nt.CastsWithInt[_ScalarT], x: _nt.SequenceND[_nt.JustInt], k: None = None, /
2441+
self: NDArray[_NumberT], x: _nt.CastsWith[_NumberT, _ScalarT], k: None = None, /
24512442
) -> NDArray[_ScalarT]: ...
24522443
@overload
2444+
def __rpow__(self: _nt.CastsWithInt[_NumberT], x: _nt.SequenceND[int], k: None = None, /) -> NDArray[_NumberT]: ...
2445+
@overload
24532446
def __rpow__(
24542447
self: _nt.CastsWithFloat[_ScalarT], x: _nt.SequenceND[_nt.JustFloat], k: None = None, /
24552448
) -> NDArray[_ScalarT]: ...
@@ -2458,8 +2451,6 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
24582451
self: _nt.CastsWithComplex[_ScalarT], x: _nt.SequenceND[_nt.JustComplex], k: None = None, /
24592452
) -> NDArray[_ScalarT]: ...
24602453
@overload
2461-
def __rpow__(self: NDArray[bool_], x: _nt.ToBool_nd, k: None = None, /) -> NDArray[int8]: ...
2462-
@overload
24632454
def __rpow__(self: NDArray[object_], x: object, k: None = None, /) -> NDArray[object_]: ...
24642455

24652456
#
@@ -2476,59 +2467,59 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
24762467

24772468
#
24782469
@overload
2470+
def __truediv__(
2471+
self: _HasDType[_HasType[_JustNumber]], x: _nt.CoFloat64_nd | _HasDType[_HasType[_JustNumber]], /
2472+
) -> NDArray[inexact]: ...
2473+
@overload
24792474
def __truediv__(self: NDArray[_InexactT], x: _nt.Casts[_InexactT], /) -> NDArray[_InexactT]: ...
24802475
@overload
2481-
def __truediv__(self: NDArray[_ScalarT], x: _nt.CastsWith[_ScalarT, _InexactT], /) -> NDArray[_InexactT]: ...
2476+
def __truediv__(self: NDArray[_ScalarT], x: _nt.CastsWith[_ScalarT, _InexactT], /) -> NDArray[_InexactT]: ... # type: ignore[overload-overlap]
24822477
@overload
24832478
def __truediv__(self: _nt.CastsWithFloat[_ScalarT], x: _nt.SequenceND[float], /) -> NDArray[_ScalarT]: ...
24842479
@overload
24852480
def __truediv__(
24862481
self: _nt.CastsWithComplex[_ScalarT], x: _nt.SequenceND[_nt.JustComplex], /
24872482
) -> NDArray[_ScalarT]: ...
24882483
@overload
2489-
def __truediv__(
2490-
self: _HasDType[_HasType[_JustNumber]], x: _nt.CoFloat64_nd | _HasDType[_HasType[_JustNumber]], /
2491-
) -> NDArray[inexact]: ...
2492-
@overload
24932484
def __truediv__(self: NDArray[_nt.co_integer], x: _nt.CoInteger_nd, /) -> NDArray[float64]: ...
24942485
@overload
24952486
def __truediv__(self: NDArray[timedelta64], x: _nt.ToTimeDelta_nd, /) -> NDArray[float64]: ...
24962487
@overload
24972488
def __truediv__(self: NDArray[timedelta64], x: _nt.ToInteger_nd | _nt.ToFloating_nd, /) -> NDArray[timedelta64]: ...
24982489
@overload
2499-
def __truediv__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ...
2500-
@overload
25012490
def __truediv__(
2502-
self: NDArray[generic[_T]], x: _nt.Sequence1ND[_nt.op.CanRTruediv[_T]], /
2491+
self: NDArray[generic[_NumberItemT]], x: _nt.Sequence1ND[_nt.op.CanRTruediv[_NumberItemT]], /
25032492
) -> NDArray[Incomplete]: ...
2493+
@overload
2494+
def __truediv__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ...
25042495

25052496
#
25062497
@overload
2498+
def __rtruediv__(
2499+
self: _HasDType[_HasType[_JustNumber]], x: _nt.CoFloat64_nd | _HasDType[_HasType[_JustNumber]], /
2500+
) -> NDArray[inexact]: ...
2501+
@overload
25072502
def __rtruediv__(self: NDArray[_InexactT], x: _nt.Casts[_InexactT], /) -> NDArray[_InexactT]: ...
25082503
@overload
2509-
def __rtruediv__(self: NDArray[_ScalarT], x: _nt.CastsWith[_ScalarT, _InexactT], /) -> NDArray[_InexactT]: ...
2504+
def __rtruediv__(self: NDArray[_ScalarT], x: _nt.CastsWith[_ScalarT, _InexactT], /) -> NDArray[_InexactT]: ... # type: ignore[overload-overlap]
25102505
@overload
25112506
def __rtruediv__(self: _nt.CastsWithFloat[_ScalarT], x: _nt.SequenceND[float], /) -> NDArray[_ScalarT]: ...
25122507
@overload
25132508
def __rtruediv__(
25142509
self: _nt.CastsWithComplex[_ScalarT], x: _nt.SequenceND[_nt.JustComplex], /
25152510
) -> NDArray[_ScalarT]: ...
25162511
@overload
2517-
def __rtruediv__(
2518-
self: _HasDType[_HasType[_JustNumber]], x: _nt.CoFloat64_nd | _HasDType[_HasType[_JustNumber]], /
2519-
) -> NDArray[inexact]: ...
2520-
@overload
25212512
def __rtruediv__(self: NDArray[_nt.co_integer], x: _nt.CoInteger_nd, /) -> NDArray[float64]: ...
25222513
@overload
25232514
def __rtruediv__(self: NDArray[timedelta64], x: _nt.ToTimeDelta_nd, /) -> NDArray[float64]: ...
25242515
@overload
25252516
def __rtruediv__(self: NDArray[integer | floating], x: _nt.ToTimeDelta_nd, /) -> NDArray[timedelta64]: ...
25262517
@overload
2527-
def __rtruediv__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ...
2528-
@overload
25292518
def __rtruediv__(
2530-
self: NDArray[generic[_T]], x: _nt.Sequence1ND[_nt.op.CanTruediv[_T]], /
2519+
self: NDArray[generic[_NumberItemT]], x: _nt.Sequence1ND[_nt.op.CanTruediv[_NumberItemT]], /
25312520
) -> NDArray[Incomplete]: ...
2521+
@overload
2522+
def __rtruediv__(self: NDArray[object_], x: object, /) -> NDArray[object_]: ...
25322523

25332524
#
25342525
@overload # type: ignore[misc]
@@ -2544,11 +2535,11 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
25442535
self: NDArray[timedelta64], x: _nt.ToInteger_nd | _nt.ToFloating_nd, /
25452536
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
25462537
@overload
2547-
def __itruediv__(self: NDArray[object_], x: object, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
2548-
@overload
25492538
def __itruediv__(
2550-
self: NDArray[generic[_T]], x: _nt.Sequence1ND[_nt.op.CanRTruediv[_T, _T]], /
2539+
self: NDArray[generic[_NumberItemT]], x: _nt.Sequence1ND[_nt.op.CanRTruediv[_NumberItemT, _NumberItemT]], /
25512540
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
2541+
@overload
2542+
def __itruediv__(self: NDArray[object_], x: object, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
25522543

25532544
# TODO(jorenham): rewrite the modular and bitwise binops below
25542545

src/numpy-stubs/ma/core.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ class MaskedArray(np.ndarray[_ShapeT_co, _DTypeT_co]):
460460
@override
461461
def __iadd__(self, other: Incomplete, /) -> Self: ... # type: ignore[override]
462462
@override
463-
def __isub__(self, other: Incomplete, /) -> Self: ... # type: ignore[override]
463+
def __isub__(self, other: Incomplete, /) -> Self: ...
464464
@override
465465
def __imul__(self, other: Incomplete, /) -> Self: ... # type: ignore[override]
466466
def __idiv__(self, other: Incomplete, /) -> Self: ...

0 commit comments

Comments
 (0)