13
13
TYPE_CHECKING ,
14
14
Any ,
15
15
Callable ,
16
+ Iterator ,
16
17
Sequence ,
17
18
TypeVar ,
18
19
cast ,
24
25
from pandas ._typing import (
25
26
ArrayLike ,
26
27
Dtype ,
28
+ FillnaOptions ,
27
29
PositionalIndexer ,
28
30
Shape ,
29
31
)
69
71
)
70
72
71
73
if TYPE_CHECKING :
74
+ from typing import Literal
72
75
73
76
class ExtensionArraySupportsAnyAll ("ExtensionArray" ):
74
77
def any (self , * , skipna : bool = True ) -> bool :
@@ -375,7 +378,7 @@ def __len__(self) -> int:
375
378
"""
376
379
raise AbstractMethodError (self )
377
380
378
- def __iter__ (self ):
381
+ def __iter__ (self ) -> Iterator [ Any ] :
379
382
"""
380
383
Iterate over elements of the array.
381
384
"""
@@ -385,7 +388,7 @@ def __iter__(self):
385
388
for i in range (len (self )):
386
389
yield self [i ]
387
390
388
- def __contains__ (self , item ) -> bool | np .bool_ :
391
+ def __contains__ (self , item : object ) -> bool | np .bool_ :
389
392
"""
390
393
Return for `item in self`.
391
394
"""
@@ -400,7 +403,9 @@ def __contains__(self, item) -> bool | np.bool_:
400
403
else :
401
404
return False
402
405
else :
403
- return (item == self ).any ()
406
+ # error: Item "ExtensionArray" of "Union[ExtensionArray, ndarray]" has no
407
+ # attribute "any"
408
+ return (item == self ).any () # type: ignore[union-attr]
404
409
405
410
# error: Signature of "__eq__" incompatible with supertype "object"
406
411
def __eq__ (self , other : Any ) -> ArrayLike : # type: ignore[override]
@@ -678,7 +683,12 @@ def argmax(self, skipna: bool = True) -> int:
678
683
raise NotImplementedError
679
684
return nargminmax (self , "argmax" )
680
685
681
- def fillna (self , value = None , method = None , limit = None ):
686
+ def fillna (
687
+ self ,
688
+ value : object | ArrayLike | None = None ,
689
+ method : FillnaOptions | None = None ,
690
+ limit : int | None = None ,
691
+ ):
682
692
"""
683
693
Fill NA/NaN values using the specified method.
684
694
@@ -1205,7 +1215,7 @@ def _formatter(self, boxed: bool = False) -> Callable[[Any], str | None]:
1205
1215
# Reshaping
1206
1216
# ------------------------------------------------------------------------
1207
1217
1208
- def transpose (self , * axes ) -> ExtensionArray :
1218
+ def transpose (self , * axes : int ) -> ExtensionArray :
1209
1219
"""
1210
1220
Return a transposed view on this array.
1211
1221
@@ -1218,7 +1228,7 @@ def transpose(self, *axes) -> ExtensionArray:
1218
1228
def T (self ) -> ExtensionArray :
1219
1229
return self .transpose ()
1220
1230
1221
- def ravel (self , order = "C" ) -> ExtensionArray :
1231
+ def ravel (self , order : Literal [ "C" , "F" , "A" , "K" ] | None = "C" ) -> ExtensionArray :
1222
1232
"""
1223
1233
Return a flattened view on this array.
1224
1234
@@ -1292,7 +1302,7 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs):
1292
1302
"""
1293
1303
raise TypeError (f"cannot perform { name } with type { self .dtype } " )
1294
1304
1295
- def __hash__ (self ):
1305
+ def __hash__ (self ) -> int :
1296
1306
raise TypeError (f"unhashable type: { repr (type (self ).__name__ )} " )
1297
1307
1298
1308
# ------------------------------------------------------------------------
0 commit comments