@@ -298,7 +298,7 @@ def __rmod__(self, other: Any) -> Self:
298298 return self ._with_native (res )
299299
300300 def __invert__ (self ) -> Self :
301- return self ._with_native (pc .invert (self .native )) # type: ignore[call-overload]
301+ return self ._with_native (pc .invert (self .native ))
302302
303303 @property
304304 def _type (self ) -> pa .DataType :
@@ -426,6 +426,7 @@ def _gather_slice(self, rows: _SliceIndex | range) -> Self:
426426 def scatter (self , indices : int | Sequence [int ], values : Any ) -> Self :
427427 import numpy as np # ignore-banned-import
428428
429+ values_native : ArrayAny
429430 if isinstance (indices , int ):
430431 indices_native = pa .array ([indices ])
431432 values_native = pa .array ([values ])
@@ -436,20 +437,25 @@ def scatter(self, indices: int | Sequence[int], values: Any) -> Self:
436437 if isinstance (values , self .__class__ ):
437438 values_native = values .native .combine_chunks ()
438439 else :
439- values_native = pa .array (values )
440+ # NOTE: Requires fixes in https://github.com/zen-xu/pyarrow-stubs/pull/209
441+ pa_array : Incomplete = pa .array
442+ values_native = pa_array (values )
440443
441- sorting_indices = pc .sort_indices (indices_native ) # type: ignore[call-overload]
442- indices_native = pc .take (indices_native , sorting_indices )
443- values_native = pc .take (values_native , sorting_indices )
444+ sorting_indices = pc .sort_indices (indices_native )
445+ indices_native = indices_native .take (sorting_indices )
446+ values_native = values_native .take (sorting_indices )
444447
445448 mask : _1DArray = np .zeros (self .len (), dtype = bool )
446449 mask [indices_native ] = True
447- result = pc .replace_with_mask (
448- self .native ,
449- cast ("list[bool]" , mask ),
450- values_native .take (indices_native ),
450+ # NOTE: Multiple issues
451+ # - Missing `values` type
452+ # - `mask` accepts a `np.ndarray`, but not mentioned in stubs
453+ # - Missing `replacements` type
454+ # - Missing return type
455+ pc_replace_with_mask : Incomplete = pc .replace_with_mask
456+ return self ._with_native (
457+ pc_replace_with_mask (self .native , mask , values_native .take (indices_native ))
451458 )
452- return self ._with_native (result )
453459
454460 def to_list (self ) -> list [Any ]:
455461 return self .native .to_pylist ()
0 commit comments