@@ -1092,35 +1092,11 @@ class _SupportsItem(Protocol[_T_co]):
1092
1092
class _SupportsDLPack (Protocol [_T_contra ]):
1093
1093
def __dlpack__ (self , / , * , stream : _T_contra | None = None ) -> CapsuleType : ...
1094
1094
1095
- @type_check_only
1096
- class _HasShape (Protocol [_ShapeT_co ]):
1097
- @property
1098
- def shape (self , / ) -> _ShapeT_co : ...
1099
-
1100
1095
@type_check_only
1101
1096
class _HasDType (Protocol [_T_co ]):
1102
1097
@property
1103
1098
def dtype (self , / ) -> _T_co : ...
1104
1099
1105
- @type_check_only
1106
- class _HasShapeAndSupportsItem (_HasShape [_ShapeT_co ], _SupportsItem [_T_co ], Protocol [_ShapeT_co , _T_co ]): ...
1107
-
1108
- # matches any `x` on `x.type.item() -> _T_co`, e.g. `dtype[np.int8]` gives `_T_co: int`
1109
- @type_check_only
1110
- class _HasTypeWithItem (Protocol [_T_co ]):
1111
- @property
1112
- def type (self , / ) -> type [_SupportsItem [_T_co ]]: ...
1113
-
1114
- # matches any `x` on `x.shape: _ShapeT_co` and `x.dtype.type.item() -> _T_co`,
1115
- # useful for capturing the item-type (`_T_co`) of the scalar-type of an array with
1116
- # specific shape (`_ShapeT_co`).
1117
- @type_check_only
1118
- class _HasShapeAndDTypeWithItem (Protocol [_ShapeT_co , _T_co ]):
1119
- @property
1120
- def shape (self , / ) -> _ShapeT_co : ...
1121
- @property
1122
- def dtype (self , / ) -> _HasTypeWithItem [_T_co ]: ...
1123
-
1124
1100
@type_check_only
1125
1101
class _HasRealAndImag (Protocol [_RealT_co , _ImagT_co ]):
1126
1102
@property
@@ -2199,29 +2175,26 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DType_co]):
2199
2175
@property
2200
2176
def flat (self ) -> flatiter [Self ]: ...
2201
2177
2202
- @overload # special casing for `StringDType`, which has no scalar type
2203
- def item (self : ndarray [Any , dtypes .StringDType ], / ) -> str : ...
2204
- @overload
2205
- def item (self : ndarray [Any , dtypes .StringDType ], arg0 : SupportsIndex | tuple [SupportsIndex , ...] = ..., / ) -> str : ...
2206
- @overload
2207
- def item (self : ndarray [Any , dtypes .StringDType ], / , * args : SupportsIndex ) -> str : ...
2208
2178
@overload # use the same output type as that of the underlying `generic`
2209
- def item (self : _HasShapeAndDTypeWithItem [Any , _T ], / ) -> _T : ...
2210
- @overload
2211
- def item (self : _HasShapeAndDTypeWithItem [Any , _T ], arg0 : SupportsIndex | tuple [SupportsIndex , ...] = ..., / ) -> _T : ...
2212
- @overload
2213
- def item (self : _HasShapeAndDTypeWithItem [Any , _T ], / , * args : SupportsIndex ) -> _T : ...
2179
+ def item (self : NDArray [generic [_T ]], i0 : SupportsIndex | tuple [SupportsIndex , ...] = ..., / , * args : SupportsIndex ) -> _T : ...
2180
+ @overload # special casing for `StringDType`, which has no scalar type
2181
+ def item (
2182
+ self : ndarray [Any , dtypes .StringDType ],
2183
+ arg0 : SupportsIndex | tuple [SupportsIndex , ...] = ...,
2184
+ / ,
2185
+ * args : SupportsIndex ,
2186
+ ) -> str : ...
2214
2187
2215
2188
@overload
2216
- def tolist (self : _HasShapeAndSupportsItem [tuple [()], _T ], / ) -> _T : ...
2189
+ def tolist (self : ndarray [tuple [()], dtype [ generic [ _T ]] ], / ) -> _T : ...
2217
2190
@overload
2218
- def tolist (self : _HasShapeAndSupportsItem [tuple [int ], _T ], / ) -> list [_T ]: ...
2191
+ def tolist (self : ndarray [tuple [int ], dtype [ generic [ _T ]] ], / ) -> list [_T ]: ...
2219
2192
@overload
2220
- def tolist (self : _HasShapeAndSupportsItem [tuple [int , int ], _T ], / ) -> list [list [_T ]]: ...
2193
+ def tolist (self : ndarray [tuple [int , int ], dtype [ generic [ _T ]] ], / ) -> list [list [_T ]]: ...
2221
2194
@overload
2222
- def tolist (self : _HasShapeAndSupportsItem [tuple [int , int , int ], _T ], / ) -> list [list [list [_T ]]]: ...
2195
+ def tolist (self : ndarray [tuple [int , int , int ], dtype [ generic [ _T ]] ], / ) -> list [list [list [_T ]]]: ...
2223
2196
@overload
2224
- def tolist (self : _HasShapeAndSupportsItem [ Any , _T ], / ) -> _T | list [ _T ] | list [ list [ _T ]] | list [ list [ list [ Any ]]] : ...
2197
+ def tolist (self , / ) -> Any : ...
2225
2198
2226
2199
@overload
2227
2200
def resize (self , new_shape : _ShapeLike , / , * , refcheck : builtins .bool = ...) -> None : ...
@@ -5364,7 +5337,7 @@ class matrix(ndarray[_2DShapeT_co, _DType_co]):
5364
5337
def ptp (self , axis : None | _ShapeLike = ..., out : _ArrayT = ...) -> _ArrayT : ...
5365
5338
5366
5339
def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [_2D , _DType_co ]: ...
5367
- def tolist (self : _SupportsItem [ _T ]) -> list [list [_T ]]: ...
5340
+ def tolist (self : matrix [ Any , dtype [ generic [ _T ]]] ) -> list [list [_T ]]: ... # pyright: ignore[reportIncompatibleMethodOverride]
5368
5341
def ravel (self , / , order : _OrderKACF = "C" ) -> matrix [tuple [L [1 ], int ], _DType_co ]: ... # pyright: ignore[reportIncompatibleMethodOverride]
5369
5342
def flatten (self , / , order : _OrderKACF = "C" ) -> matrix [tuple [L [1 ], int ], _DType_co ]: ... # pyright: ignore[reportIncompatibleMethodOverride]
5370
5343
0 commit comments