diff --git a/pandas/_libs/internals.pyi b/pandas/_libs/internals.pyi index 143f6b68deaa6..79bdbea71e4d8 100644 --- a/pandas/_libs/internals.pyi +++ b/pandas/_libs/internals.pyi @@ -44,7 +44,9 @@ class BlockPlacement: @property def is_slice_like(self) -> bool: ... @overload - def __getitem__(self, loc: slice | Sequence[int]) -> BlockPlacement: ... + def __getitem__( + self, loc: slice | Sequence[int] | npt.NDArray[np.intp] + ) -> BlockPlacement: ... @overload def __getitem__(self, loc: int) -> int: ... def __iter__(self) -> Iterator[int]: ... diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 8fb6a18ca137a..b7da5d82c85f3 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -258,9 +258,7 @@ def getitem_block(self, slicer: slice | npt.NDArray[np.intp]) -> Block: # is from internals.concat, and we can verify that never happens # with 1-column blocks, i.e. never for ExtensionBlock. - # Invalid index type "Union[slice, ndarray[Any, dtype[signedinteger[Any]]]]" - # for "BlockPlacement"; expected type "Union[slice, Sequence[int]]" - new_mgr_locs = self._mgr_locs[slicer] # type: ignore[index] + new_mgr_locs = self._mgr_locs[slicer] new_values = self._slice(slicer) diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 71d8b20f18457..81c5810d29456 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -1320,11 +1320,11 @@ def _iset_split_block( nbs_tup = tuple(blk.delete(blk_locs)) if value is not None: - # error: No overload variant of "__getitem__" of "BlockPlacement" matches - # argument type "ndarray[Any, Any]" [call-overload] + # Argument 1 to "BlockPlacement" has incompatible type "BlockPlacement"; + # expected "Union[int, slice, ndarray[Any, Any]]" first_nb = new_block_2d( value, - BlockPlacement(blk.mgr_locs[blk_locs]), # type: ignore[call-overload] + BlockPlacement(blk.mgr_locs[blk_locs]), # type: ignore[arg-type] ) else: first_nb = nbs_tup[0]