1
1
from typing import (
2
2
Literal as L ,
3
3
overload ,
4
+ TypeAlias ,
4
5
TypeVar ,
5
6
Any ,
6
7
SupportsIndex ,
@@ -17,7 +18,6 @@ from numpy import (
17
18
object_ ,
18
19
_OrderKACF ,
19
20
_ShapeType_co ,
20
- _CharDType ,
21
21
_SupportsBuffer ,
22
22
)
23
23
@@ -33,10 +33,15 @@ from numpy._typing import (
33
33
34
34
from numpy ._core .multiarray import compare_chararrays as compare_chararrays
35
35
36
- _SCT = TypeVar ("_SCT" , str_ , bytes_ )
37
- _CharArray = chararray [_Shape , dtype [_SCT ]]
36
+ _SCT = TypeVar ("_SCT" , bound = str_ | bytes_ )
37
+ _CharDType_co = TypeVar (
38
+ "_CharDType_co" ,
39
+ bound = dtype [str_ | bytes_ ],
40
+ covariant = True ,
41
+ )
42
+ _CharArray : TypeAlias = chararray [tuple [int , ...], dtype [_SCT ]]
38
43
39
- class chararray (ndarray [_ShapeType_co , _CharDType ]):
44
+ class chararray (ndarray [_ShapeType_co , _CharDType_co ]):
40
45
@overload
41
46
def __new__ (
42
47
subtype ,
@@ -61,9 +66,9 @@ class chararray(ndarray[_ShapeType_co, _CharDType]):
61
66
) -> chararray [_Shape , dtype [str_ ]]: ...
62
67
63
68
def __array_finalize__ (self , obj : object ) -> None : ...
64
- def __mul__ (self , other : i_co ) -> chararray [_Shape , _CharDType ]: ...
65
- def __rmul__ (self , other : i_co ) -> chararray [_Shape , _CharDType ]: ...
66
- def __mod__ (self , i : Any ) -> chararray [_Shape , _CharDType ]: ...
69
+ def __mul__ (self , other : i_co ) -> chararray [_Shape , _CharDType_co ]: ...
70
+ def __rmul__ (self , other : i_co ) -> chararray [_Shape , _CharDType_co ]: ...
71
+ def __mod__ (self , i : Any ) -> chararray [_Shape , _CharDType_co ]: ...
67
72
68
73
@overload
69
74
def __eq__ (
@@ -211,7 +216,7 @@ class chararray(ndarray[_ShapeType_co, _CharDType]):
211
216
def expandtabs (
212
217
self ,
213
218
tabsize : i_co = ...,
214
- ) -> chararray [_Shape , _CharDType ]: ...
219
+ ) -> chararray [_Shape , _CharDType_co ]: ...
215
220
216
221
@overload
217
222
def find (
@@ -436,12 +441,12 @@ class chararray(ndarray[_ShapeType_co, _CharDType]):
436
441
deletechars : None | S_co = ...,
437
442
) -> _CharArray [bytes_ ]: ...
438
443
439
- def zfill (self , width : _ArrayLikeInt_co ) -> chararray [_Shape , _CharDType ]: ...
440
- def capitalize (self ) -> chararray [_ShapeType_co , _CharDType ]: ...
441
- def title (self ) -> chararray [_ShapeType_co , _CharDType ]: ...
442
- def swapcase (self ) -> chararray [_ShapeType_co , _CharDType ]: ...
443
- def lower (self ) -> chararray [_ShapeType_co , _CharDType ]: ...
444
- def upper (self ) -> chararray [_ShapeType_co , _CharDType ]: ...
444
+ def zfill (self , width : _ArrayLikeInt_co ) -> chararray [_Shape , _CharDType_co ]: ...
445
+ def capitalize (self ) -> chararray [_ShapeType_co , _CharDType_co ]: ...
446
+ def title (self ) -> chararray [_ShapeType_co , _CharDType_co ]: ...
447
+ def swapcase (self ) -> chararray [_ShapeType_co , _CharDType_co ]: ...
448
+ def lower (self ) -> chararray [_ShapeType_co , _CharDType_co ]: ...
449
+ def upper (self ) -> chararray [_ShapeType_co , _CharDType_co ]: ...
445
450
def isalnum (self ) -> ndarray [_ShapeType_co , dtype [np .bool ]]: ...
446
451
def isalpha (self ) -> ndarray [_ShapeType_co , dtype [np .bool ]]: ...
447
452
def isdigit (self ) -> ndarray [_ShapeType_co , dtype [np .bool ]]: ...
0 commit comments