Skip to content

Commit 0237f7a

Browse files
committed
fix(typing): resolve for pyarrow-stubs>=17.18
#2113 (comment)
1 parent 9fba61f commit 0237f7a

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

narwhals/_arrow/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def func(df: ArrowDataFrame) -> Sequence[ArrowSeries]:
164164
# again calling `sort_indices`. `ArrowSeries.scatter` would also sort.
165165
sorting_indices = pc.sort_indices(df[token]._native_series) # type: ignore[call-overload]
166166
return [
167-
ser._from_native_series(pc.take(ser._native_series, sorting_indices)) # type: ignore[call-overload]
167+
ser._from_native_series(pc.take(ser._native_series, sorting_indices))
168168
for ser in result
169169
]
170170
else:

narwhals/_arrow/series.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def fill_aux(
674674

675675
if value is not None:
676676
_, value = extract_native(self, value)
677-
series = pc.fill_null(self.native, value) # type: ignore[attr-defined]
677+
series = pc.fill_null(self.native, value)
678678
elif limit is None:
679679
fill_func = (
680680
pc.fill_null_forward if strategy == "forward" else pc.fill_null_backward
@@ -1100,19 +1100,11 @@ def _hist_from_bin_count(bin_count: int): # type: ignore[no-untyped-def] # noqa
11001100
range_ = pc.subtract(upper, lower)
11011101
width = pc.divide(pc.cast(range_, pa_float), lit(float(bin_count)))
11021102

1103-
bin_proportions = pc.divide(
1104-
pc.subtract(cast("pc.NumericOrTemporalArray", self.native), lower),
1105-
width,
1106-
)
1107-
bin_indices: ArrowChunkedArray = cast(
1108-
"ArrowChunkedArray", pc.floor(bin_proportions)
1109-
)
1110-
1111-
# NOTE: stubs leave unannotated
1112-
if_else: Incomplete = pc.if_else
1103+
bin_proportions = pc.divide(pc.subtract(self.native, lower), width)
1104+
bin_indices = pc.floor(bin_proportions)
11131105

11141106
# shift bins so they are right-closed
1115-
bin_indices = if_else(
1107+
bin_indices = pc.if_else(
11161108
pc.and_(
11171109
pc.equal(bin_indices, bin_proportions),
11181110
pc.greater(bin_indices, 0),

tests/series_only/is_ordered_categorical_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ def test_is_definitely_not_ordered_categorical(
5454
@pytest.mark.xfail(reason="https://github.com/apache/arrow/issues/41017")
5555
def test_is_ordered_categorical_pyarrow() -> None:
5656
tp = pa.dictionary(pa.int32(), pa.string(), ordered=True)
57-
s = pa.chunked_array([pa.array(["a", "b"], type=tp)]) # type: ignore[list-item]
57+
arr = pa.array(["a", "b"], type=tp)
58+
s = pa.chunked_array([arr], type=tp)
5859
assert nw.is_ordered_categorical(nw.from_native(s, series_only=True))

0 commit comments

Comments
 (0)