@@ -367,14 +367,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
367367 # "Union[int, integer[Any]]"
368368 return self .values [i ] # type: ignore[index]
369369
370- def set_inplace (self , locs , values ) -> None :
370+ def set_inplace (self , locs , values : ArrayLike ) -> None :
371371 """
372372 Modify block values in-place with new item value.
373373
374374 Notes
375375 -----
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.
378380 """
379381 self .values [locs ] = values
380382
@@ -1181,7 +1183,7 @@ def where(self, other, cond) -> list[Block]:
11811183 icond , noop = validate_putmask (values , ~ cond )
11821184 if noop :
11831185 # GH-39595: Always return a copy; short-circuit up/downcasting
1184- return self .copy ()
1186+ return [ self .copy ()]
11851187
11861188 if other is lib .no_default :
11871189 other = self .fill_value
@@ -1373,7 +1375,8 @@ def setitem(self, indexer, value):
13731375
13741376 values = self .values
13751377 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
13771380 values = values .T
13781381 check_setitem_lengths (indexer , value , values )
13791382 values [indexer ] = value
@@ -1394,7 +1397,7 @@ def where(self, other, cond) -> list[Block]:
13941397 if noop :
13951398 # GH#44181, GH#45135
13961399 # Avoid a) raising for Interval/PeriodDtype and b) unnecessary object upcast
1397- return self .copy ()
1400+ return [ self .copy ()]
13981401
13991402 try :
14001403 res_values = arr ._where (cond , other ).T
@@ -1596,12 +1599,16 @@ def iget(self, i: int | tuple[int, int] | tuple[slice, int]):
15961599 raise IndexError (f"{ self } only contains one item" )
15971600 return self .values
15981601
1599- def set_inplace (self , locs , values ) -> None :
1602+ def set_inplace (self , locs , values : ArrayLike ) -> None :
16001603 # NB: This is a misnomer, is supposed to be inplace but is not,
16011604 # see GH#33457
16021605 # When an ndarray, we should have locs.tolist() == [0]
16031606 # 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]
16051612 try :
16061613 # TODO(GH33457) this can be removed
16071614 self ._cache .clear ()
0 commit comments