@@ -295,7 +295,7 @@ def __repr__(self) -> str:
295
295
def __len__ (self ) -> int :
296
296
return len (self .values )
297
297
298
- def _slice (self , slicer ):
298
+ def _slice (self , slicer ) -> ArrayLike :
299
299
"""return a slice of my values"""
300
300
301
301
return self .values [slicer ]
@@ -344,7 +344,7 @@ def dtype(self) -> DtypeObj:
344
344
def iget (self , i ):
345
345
return self .values [i ]
346
346
347
- def set_inplace (self , locs , values ):
347
+ def set_inplace (self , locs , values ) -> None :
348
348
"""
349
349
Modify block values in-place with new item value.
350
350
@@ -563,13 +563,13 @@ def _downcast_2d(self) -> list[Block]:
563
563
return [self .make_block (new_values )]
564
564
565
565
@final
566
- def astype (self , dtype , copy : bool = False , errors : str = "raise" ):
566
+ def astype (self , dtype : DtypeObj , copy : bool = False , errors : str = "raise" ):
567
567
"""
568
568
Coerce to the new dtype.
569
569
570
570
Parameters
571
571
----------
572
- dtype : str, dtype convertible
572
+ dtype : np. dtype or ExtensionDtype
573
573
copy : bool, default False
574
574
copy if indicated
575
575
errors : str, {'raise', 'ignore'}, default 'raise'
@@ -1441,7 +1441,7 @@ def iget(self, col):
1441
1441
raise IndexError (f"{ self } only contains one item" )
1442
1442
return self .values
1443
1443
1444
- def set_inplace (self , locs , values ):
1444
+ def set_inplace (self , locs , values ) -> None :
1445
1445
# NB: This is a misnomer, is supposed to be inplace but is not,
1446
1446
# see GH#33457
1447
1447
assert locs .tolist () == [0 ]
@@ -1509,7 +1509,7 @@ def setitem(self, indexer, value):
1509
1509
# https://github.com/pandas-dev/pandas/issues/24020
1510
1510
# Need a dedicated setitem until GH#24020 (type promotion in setitem
1511
1511
# for extension arrays) is designed and implemented.
1512
- return self .astype (object ).setitem (indexer , value )
1512
+ return self .astype (_dtype_obj ).setitem (indexer , value )
1513
1513
1514
1514
if isinstance (indexer , tuple ):
1515
1515
# TODO(EA2D): not needed with 2D EAs
@@ -1547,7 +1547,7 @@ def take_nd(
1547
1547
1548
1548
return self .make_block_same_class (new_values , new_mgr_locs )
1549
1549
1550
- def _slice (self , slicer ):
1550
+ def _slice (self , slicer ) -> ExtensionArray :
1551
1551
"""
1552
1552
Return a slice of my values.
1553
1553
@@ -1558,7 +1558,7 @@ def _slice(self, slicer):
1558
1558
1559
1559
Returns
1560
1560
-------
1561
- np.ndarray or ExtensionArray
1561
+ ExtensionArray
1562
1562
"""
1563
1563
# return same dims as we currently have
1564
1564
if not isinstance (slicer , tuple ) and self .ndim == 2 :
@@ -1736,7 +1736,7 @@ def is_view(self) -> bool:
1736
1736
def setitem (self , indexer , value ):
1737
1737
if not self ._can_hold_element (value ):
1738
1738
# TODO: general case needs casting logic.
1739
- return self .astype (object ).setitem (indexer , value )
1739
+ return self .astype (_dtype_obj ).setitem (indexer , value )
1740
1740
1741
1741
values = self .values
1742
1742
if self .ndim > 1 :
@@ -1750,7 +1750,7 @@ def putmask(self, mask, new) -> list[Block]:
1750
1750
mask = extract_bool_array (mask )
1751
1751
1752
1752
if not self ._can_hold_element (new ):
1753
- return self .astype (object ).putmask (mask , new )
1753
+ return self .astype (_dtype_obj ).putmask (mask , new )
1754
1754
1755
1755
arr = self .values
1756
1756
arr .T .putmask (mask , new )
@@ -1808,7 +1808,7 @@ def fillna(
1808
1808
# We support filling a DatetimeTZ with a `value` whose timezone
1809
1809
# is different by coercing to object.
1810
1810
# TODO: don't special-case td64
1811
- return self .astype (object ).fillna (value , limit , inplace , downcast )
1811
+ return self .astype (_dtype_obj ).fillna (value , limit , inplace , downcast )
1812
1812
1813
1813
values = self .values
1814
1814
values = values if inplace else values .copy ()
0 commit comments