@@ -1776,11 +1776,11 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
1776
1776
@overload
1777
1777
def __getitem__ (
1778
1778
self , key : _ArrayInteger_co | tuple [_ArrayInteger_co , ...], /
1779
- ) -> ndarray [_nt .Shape , _DTypeT_co ]: ...
1779
+ ) -> ndarray [_nt .AnyShape , _DTypeT_co ]: ...
1780
1780
@overload
1781
1781
def __getitem__ (self , key : CanIndex | tuple [CanIndex , ...], / ) -> Any : ...
1782
1782
@overload
1783
- def __getitem__ (self , key : _ToIndices , / ) -> ndarray [_nt .Shape , _DTypeT_co ]: ...
1783
+ def __getitem__ (self , key : _ToIndices , / ) -> ndarray [_nt .AnyShape , _DTypeT_co ]: ...
1784
1784
@overload
1785
1785
def __getitem__ (self : _nt .Array [void ], key : str , / ) -> ndarray [_ShapeT_co ]: ...
1786
1786
@overload
@@ -2452,55 +2452,47 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2452
2452
2453
2453
#
2454
2454
@overload
2455
- def __divmod__ (self : _nt .Array [bool_ , _nt . Shape ], x : _nt .ToBool_nd , / ) -> _Tuple2 [_nt .Array [int8 ]]: ...
2455
+ def __divmod__ (self : _nt .Array [bool_ ], x : _nt .ToBool_nd , / ) -> _Tuple2 [_nt .Array [int8 ]]: ...
2456
2456
@overload
2457
2457
def __divmod__ (
2458
- self : _nt .Array [_RealNumberT , _nt . Shape ], x : _nt .Casts [_RealNumberT , _nt . Shape ] | _nt .ToBool_nd , /
2458
+ self : _nt .Array [_RealNumberT ], x : _nt .Casts [_RealNumberT ] | _nt .ToBool_nd , /
2459
2459
) -> _Tuple2 [_nt .Array [_RealNumberT ]]: ...
2460
2460
@overload
2461
2461
def __divmod__ (
2462
- self : _nt .Array [_CoFloatingT , _nt . Shape ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT , _nt . Shape ], /
2462
+ self : _nt .Array [_CoFloatingT ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT ], /
2463
2463
) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2464
2464
@overload
2465
- def __divmod__ (
2466
- self : _nt .CastsWithInt [_RealScalarT , _nt .Shape ], x : _PyIntND , /
2467
- ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2465
+ def __divmod__ (self : _nt .CastsWithInt [_RealScalarT ], x : _PyIntND , / ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2468
2466
@overload
2469
- def __divmod__ (
2470
- self : _nt .CastsWithFloat [_RealScalarT , _nt .Shape ], x : _PyFloatND , /
2471
- ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2467
+ def __divmod__ (self : _nt .CastsWithFloat [_RealScalarT ], x : _PyFloatND , / ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2472
2468
@overload
2473
2469
def __divmod__ (
2474
- self : _nt .Array [timedelta64 , _nt . Shape ], x : _nt .ToTimeDelta_nd , /
2470
+ self : _nt .Array [timedelta64 ], x : _nt .ToTimeDelta_nd , /
2475
2471
) -> tuple [_nt .Array [int64 ], _nt .Array [timedelta64 ]]: ...
2476
2472
@overload
2477
- def __divmod__ (self : _nt .Array [object_ , _nt . Shape ], x : object , / ) -> _Tuple2 [_nt .Array [object_ ]]: ...
2473
+ def __divmod__ (self : _nt .Array [object_ ], x : object , / ) -> _Tuple2 [_nt .Array [object_ ]]: ...
2478
2474
2479
2475
#
2480
2476
@overload
2481
- def __rdivmod__ (self : _nt .Array [bool_ , _nt . Shape ], x : _nt .ToBool_nd , / ) -> _Tuple2 [_nt .Array [int8 ]]: ...
2477
+ def __rdivmod__ (self : _nt .Array [bool_ ], x : _nt .ToBool_nd , / ) -> _Tuple2 [_nt .Array [int8 ]]: ...
2482
2478
@overload
2483
2479
def __rdivmod__ (
2484
- self : _nt .Array [_RealNumberT , _nt . Shape ], x : _nt .Casts [_RealNumberT , _nt . Shape ] | _nt .ToBool_nd , /
2480
+ self : _nt .Array [_RealNumberT ], x : _nt .Casts [_RealNumberT ] | _nt .ToBool_nd , /
2485
2481
) -> _Tuple2 [_nt .Array [_RealNumberT ]]: ...
2486
2482
@overload
2487
2483
def __rdivmod__ (
2488
- self : _nt .Array [_CoFloatingT , _nt . Shape ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT , _nt . Shape ], /
2484
+ self : _nt .Array [_CoFloatingT ], x : _nt .CastsWith [_CoFloatingT , _RealScalarT ], /
2489
2485
) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2490
2486
@overload
2491
- def __rdivmod__ (
2492
- self : _nt .CastsWithInt [_RealScalarT , _nt .Shape ], x : _PyIntND , /
2493
- ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2487
+ def __rdivmod__ (self : _nt .CastsWithInt [_RealScalarT ], x : _PyIntND , / ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2494
2488
@overload
2495
- def __rdivmod__ (
2496
- self : _nt .CastsWithFloat [_RealScalarT , _nt .Shape ], x : _PyFloatND , /
2497
- ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2489
+ def __rdivmod__ (self : _nt .CastsWithFloat [_RealScalarT ], x : _PyFloatND , / ) -> _Tuple2 [_nt .Array [_RealScalarT ]]: ...
2498
2490
@overload
2499
2491
def __rdivmod__ (
2500
- self : _nt .Array [timedelta64 , _nt . Shape ], x : _nt .ToTimeDelta_nd , /
2492
+ self : _nt .Array [timedelta64 ], x : _nt .ToTimeDelta_nd , /
2501
2493
) -> tuple [_nt .Array [int64 ], _nt .Array [timedelta64 ]]: ...
2502
2494
@overload
2503
- def __rdivmod__ (self : _nt .Array [object_ , _nt . Shape ], x : object , / ) -> _Tuple2 [_nt .Array [object_ ]]: ...
2495
+ def __rdivmod__ (self : _nt .Array [object_ ], x : object , / ) -> _Tuple2 [_nt .Array [object_ ]]: ...
2504
2496
2505
2497
#
2506
2498
@overload
@@ -2701,8 +2693,12 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2701
2693
def item (self : _HasDTypeWithItem [_T ], / , * args : CanIndex ) -> _T : ...
2702
2694
2703
2695
#
2704
- @overload # TODO(jorenham): remove `| Rank0` once python/mypy#19110 is fixed
2705
- def tolist (self : _HasShapeAndItem [_nt .Shape0 | _nt .Rank0 , _T ], / ) -> _T : ... # type: ignore[overload-overlap]
2696
+ @overload # workaround for python/mypy#19110
2697
+ def tolist (self : _HasShapeAndItem [_nt .Rank0 , _T ], / ) -> _T : ... # type: ignore[overload-overlap]
2698
+ @overload # workaround for microsoft/pyright#10232
2699
+ def tolist (self : ndarray [_nt .NeitherShape ], / ) -> Any : ...
2700
+ @overload
2701
+ def tolist (self : _HasShapeAndItem [_nt .Shape0 , _T ], / ) -> _T : ...
2706
2702
@overload
2707
2703
def tolist (self : _HasShapeAndItem [_nt .Shape1 , _T ], / ) -> list [_T ]: ...
2708
2704
@overload
@@ -2741,7 +2737,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2741
2737
2742
2738
#
2743
2739
def swapaxes (self , / , axis1 : CanIndex , axis2 : CanIndex ) -> Self : ...
2744
- def squeeze (self , / , axis : CanIndex | tuple [CanIndex , ...] | None = None ) -> ndarray [_nt .Shape , _DTypeT_co ]: ...
2740
+ def squeeze (self , / , axis : CanIndex | tuple [CanIndex , ...] | None = None ) -> ndarray [_nt .AnyShape , _DTypeT_co ]: ...
2745
2741
def byteswap (self , / , inplace : py_bool = False ) -> Self : ...
2746
2742
2747
2743
#
@@ -2751,6 +2747,10 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2751
2747
def transpose (self , / , * axes : CanIndex ) -> Self : ...
2752
2748
2753
2749
# NOTE: always raises when called on `generic`.
2750
+ @overload # this overload is a workaround for microsoft/pyright#10232
2751
+ def diagonal ( # type: ignore[overload-overlap]
2752
+ self : ndarray [_nt .NeitherShape , _DTypeT ], / , offset : CanIndex = 0 , axis1 : CanIndex = 0 , axis2 : CanIndex = 1
2753
+ ) -> ndarray [_nt .AnyShape , _DTypeT ]: ...
2754
2754
@overload
2755
2755
def diagonal (
2756
2756
self : ndarray [_nt .Shape2 , _DTypeT ], / , offset : CanIndex = 0 , axis1 : CanIndex = 0 , axis2 : CanIndex = 1
@@ -2770,7 +2770,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2770
2770
@overload
2771
2771
def diagonal (
2772
2772
self , / , offset : CanIndex = 0 , axis1 : CanIndex = 0 , axis2 : CanIndex = 1
2773
- ) -> ndarray [Any , _DTypeT_co ]: ...
2773
+ ) -> ndarray [_nt . AnyShape , _DTypeT_co ]: ...
2774
2774
2775
2775
#
2776
2776
@overload
@@ -2995,7 +2995,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2995
2995
@overload
2996
2996
def take (
2997
2997
self , / , indices : _nt .CoInteger_nd , axis : CanIndex | None = None , out : None = None , mode : _ModeKind = "raise"
2998
- ) -> ndarray [_nt .Shape , _DTypeT_co ]: ...
2998
+ ) -> ndarray [_nt .AnyShape , _DTypeT_co ]: ...
2999
2999
@overload
3000
3000
def take (
3001
3001
self , / , indices : _nt .CoInteger_nd , axis : CanIndex | None , out : _ArrayT , mode : _ModeKind = "raise"
0 commit comments