@@ -367,14 +367,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
367
367
# "Union[int, integer[Any]]"
368
368
return self .values [i ] # type: ignore[index]
369
369
370
- def set_inplace (self , locs , values ) -> None :
370
+ def set_inplace (self , locs , values : ArrayLike ) -> None :
371
371
"""
372
372
Modify block values in-place with new item value.
373
373
374
374
Notes
375
375
-----
376
- `set` never creates a new array or new Block, whereas `setitem` _may_
377
- create a new array and always creates a new Block.
376
+ `set_inplace` never creates a new array or new Block, whereas `setitem`
377
+ _may_ create a new array and always creates a new Block.
378
+
379
+ Caller is responsible for checking values.dtype == self.dtype.
378
380
"""
379
381
self .values [locs ] = values
380
382
@@ -1181,7 +1183,7 @@ def where(self, other, cond) -> list[Block]:
1181
1183
icond , noop = validate_putmask (values , ~ cond )
1182
1184
if noop :
1183
1185
# GH-39595: Always return a copy; short-circuit up/downcasting
1184
- return self .copy ()
1186
+ return [ self .copy ()]
1185
1187
1186
1188
if other is lib .no_default :
1187
1189
other = self .fill_value
@@ -1373,7 +1375,8 @@ def setitem(self, indexer, value):
1373
1375
1374
1376
values = self .values
1375
1377
if values .ndim == 2 :
1376
- # TODO: string[pyarrow] tests break if we transpose unconditionally
1378
+ # TODO(GH#45419): string[pyarrow] tests break if we transpose
1379
+ # unconditionally
1377
1380
values = values .T
1378
1381
check_setitem_lengths (indexer , value , values )
1379
1382
values [indexer ] = value
@@ -1394,7 +1397,7 @@ def where(self, other, cond) -> list[Block]:
1394
1397
if noop :
1395
1398
# GH#44181, GH#45135
1396
1399
# Avoid a) raising for Interval/PeriodDtype and b) unnecessary object upcast
1397
- return self .copy ()
1400
+ return [ self .copy ()]
1398
1401
1399
1402
try :
1400
1403
res_values = arr ._where (cond , other ).T
@@ -1596,12 +1599,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
1596
1599
raise IndexError (f"{ self } only contains one item" )
1597
1600
return self .values
1598
1601
1599
- def set_inplace (self , locs , values ) -> None :
1602
+ def set_inplace (self , locs , values : ArrayLike ) -> None :
1600
1603
# NB: This is a misnomer, is supposed to be inplace but is not,
1601
1604
# see GH#33457
1602
1605
# When an ndarray, we should have locs.tolist() == [0]
1603
1606
# When a BlockPlacement we should have list(locs) == [0]
1604
- self .values = values
1607
+
1608
+ # error: Incompatible types in assignment (expression has type
1609
+ # "Union[ExtensionArray, ndarray[Any, Any]]", variable has type
1610
+ # "ExtensionArray")
1611
+ self .values = values # type: ignore[assignment]
1605
1612
try :
1606
1613
# TODO(GH33457) this can be removed
1607
1614
self ._cache .clear ()
0 commit comments