@@ -102,7 +102,9 @@ _ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], covariant=True)
102
102
_ScalarT = TypeVar ("_ScalarT" , bound = np .generic )
103
103
_ScalarT_co = TypeVar ("_ScalarT_co" , bound = np .generic , covariant = True )
104
104
_ScalarT0 = TypeVar ("_ScalarT0" , bound = np .generic , default = Any )
105
- _NaObjectT = TypeVar ("_NaObjectT" , default = Never )
105
+ _NaT = TypeVar ("_NaT" , default = Never )
106
+ _NaT0 = TypeVar ("_NaT0" , default = Any )
107
+ _NaT_co = TypeVar ("_NaT_co" , covariant = True )
106
108
_ToT = TypeVar ("_ToT" )
107
109
108
110
###
@@ -139,8 +141,8 @@ class CanLenArray(Protocol[_ScalarT_co, _ShapeT_co]):
139
141
def __array__ (self , / ) -> np .ndarray [_ShapeT_co , np .dtype [_ScalarT_co ]]: ...
140
142
141
143
@type_check_only
142
- class _CanStringArray (Protocol [_ShapeT_co ]):
143
- def __array__ (self , / ) -> np .ndarray [_ShapeT_co , np .dtypes .StringDType ]: ...
144
+ class _CanStringArray (Protocol [_ShapeT_co , _NaT_co ]):
145
+ def __array__ (self , / ) -> np .ndarray [_ShapeT_co , np .dtypes .StringDType [ _NaT_co ] ]: ...
144
146
145
147
###
146
148
# Shape aliases
@@ -184,33 +186,33 @@ Matrix = TypeAliasType("Matrix", np.matrix[tuple[int, int], np.dtype[_ScalarT0]]
184
186
185
187
StringArray = TypeAliasType (
186
188
"StringArray" ,
187
- np .ndarray [_ShapeT , np .dtypes .StringDType [_NaObjectT ]],
188
- type_params = (_ShapeT , _NaObjectT ),
189
+ np .ndarray [_ShapeT , np .dtypes .StringDType [_NaT ]],
190
+ type_params = (_ShapeT , _NaT ),
189
191
)
190
192
StringArray0D = TypeAliasType (
191
193
"StringArray0D" ,
192
- np .ndarray [tuple [()], np .dtypes .StringDType [_NaObjectT ]],
193
- type_params = (_NaObjectT ,),
194
+ np .ndarray [tuple [()], np .dtypes .StringDType [_NaT ]],
195
+ type_params = (_NaT ,),
194
196
)
195
197
StringArray1D = TypeAliasType (
196
198
"StringArray1D" ,
197
- np .ndarray [tuple [int ], np .dtypes .StringDType [_NaObjectT ]],
198
- type_params = (_NaObjectT ,),
199
+ np .ndarray [tuple [int ], np .dtypes .StringDType [_NaT ]],
200
+ type_params = (_NaT ,),
199
201
)
200
202
StringArray2D = TypeAliasType (
201
203
"StringArray2D" ,
202
- np .ndarray [tuple [int , int ], np .dtypes .StringDType [_NaObjectT ]],
203
- type_params = (_NaObjectT ,),
204
+ np .ndarray [tuple [int , int ], np .dtypes .StringDType [_NaT ]],
205
+ type_params = (_NaT ,),
204
206
)
205
207
StringArray3D = TypeAliasType (
206
208
"StringArray3D" ,
207
- np .ndarray [tuple [int , int , int ], np .dtypes .StringDType [_NaObjectT ]],
208
- type_params = (_NaObjectT ,),
209
+ np .ndarray [tuple [int , int , int ], np .dtypes .StringDType [_NaT ]],
210
+ type_params = (_NaT ,),
209
211
)
210
212
StringArrayND = TypeAliasType (
211
213
"StringArrayND" ,
212
- np .ndarray [tuple [int , ...], np .dtypes .StringDType [_NaObjectT ]],
213
- type_params = (_NaObjectT ,),
214
+ np .ndarray [tuple [int , ...], np .dtypes .StringDType [_NaT ]],
215
+ type_params = (_NaT ,),
214
216
)
215
217
216
218
###
@@ -670,13 +672,13 @@ ToObject_2nd = TypeAliasType("ToObject_2nd", _ToArray2_2nd[np.object_, _PyObject
670
672
ToObject_3nd = TypeAliasType ("ToObject_3nd" , _ToArray2_3nd [np .object_ , _PyObject ])
671
673
672
674
# StringDType
673
- ToString_nd = TypeAliasType ("ToString_nd" , _CanStringArray [AtLeast0D ] )
674
- ToString_1ds = TypeAliasType ("ToString_1ds" , _CanStringArray [tuple [int ]] )
675
- ToString_2ds = TypeAliasType ("ToString_2ds" , _CanStringArray [tuple [int , int ]] )
676
- ToString_3ds = TypeAliasType ("ToString_3ds" , _CanStringArray [tuple [int , int , int ]] )
677
- ToString_1nd = TypeAliasType ("ToString_1nd" , _CanStringArray [AtLeast1D ] )
678
- ToString_2nd = TypeAliasType ("ToString_2nd" , _CanStringArray [AtLeast2D ] )
679
- ToString_3nd = TypeAliasType ("ToString_3nd" , _CanStringArray [AtLeast3D ] )
675
+ ToString_nd = TypeAliasType ("ToString_nd" , _CanStringArray [AtLeast0D , _NaT0 ], type_params = ( _NaT0 ,) )
676
+ ToString_1ds = TypeAliasType ("ToString_1ds" , _CanStringArray [tuple [int ], _NaT0 ], type_params = ( _NaT0 ,) )
677
+ ToString_2ds = TypeAliasType ("ToString_2ds" , _CanStringArray [tuple [int , int ], _NaT0 ], type_params = ( _NaT0 ,) )
678
+ ToString_3ds = TypeAliasType ("ToString_3ds" , _CanStringArray [tuple [int , int , int ], _NaT0 ], type_params = ( _NaT0 ,) )
679
+ ToString_1nd = TypeAliasType ("ToString_1nd" , _CanStringArray [AtLeast1D , _NaT0 ], type_params = ( _NaT0 ,) )
680
+ ToString_2nd = TypeAliasType ("ToString_2nd" , _CanStringArray [AtLeast2D , _NaT0 ], type_params = ( _NaT0 ,) )
681
+ ToString_3nd = TypeAliasType ("ToString_3nd" , _CanStringArray [AtLeast3D , _NaT0 ], type_params = ( _NaT0 ,) )
680
682
681
683
# any scalar
682
684
ToGeneric_nd = TypeAliasType ("ToGeneric_nd" , _ToArray2_nd [np .generic , _PyScalar ])
0 commit comments