Skip to content

Commit 6d19ba0

Browse files
authored
Merge branch 'main' into more-dedup-1
2 parents 253e2ea + eb60314 commit 6d19ba0

37 files changed

+162
-160
lines changed

narwhals/_arrow/dataframe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
from narwhals._arrow.namespace import ArrowNamespace
4747
from narwhals._arrow.series import ArrowSeries
4848
from narwhals._arrow.typing import ArrowChunkedArray
49-
from narwhals._arrow.typing import Indices
50-
from narwhals._arrow.typing import Mask
51-
from narwhals._arrow.typing import Order
49+
from narwhals._arrow.typing import Indices # type: ignore[attr-defined]
50+
from narwhals._arrow.typing import Mask # type: ignore[attr-defined]
51+
from narwhals._arrow.typing import Order # type: ignore[attr-defined]
5252
from narwhals.dtypes import DType
5353
from narwhals.typing import SizeUnit
5454
from narwhals.typing import _1DArray

narwhals/_arrow/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def func(df: ArrowDataFrame) -> list[ArrowSeries]:
113113
func,
114114
depth=0,
115115
function_name="col",
116-
evaluate_output_names=lambda _df: list(column_names),
116+
evaluate_output_names=lambda _df: column_names,
117117
alias_output_names=None,
118118
backend_version=backend_version,
119119
version=version,

narwhals/_arrow/series.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
from narwhals._arrow.typing import ArrowArray
4545
from narwhals._arrow.typing import ArrowChunkedArray
4646
from narwhals._arrow.typing import Incomplete
47-
from narwhals._arrow.typing import Indices
47+
from narwhals._arrow.typing import Indices # type: ignore[attr-defined]
4848
from narwhals._arrow.typing import NullPlacement
49-
from narwhals._arrow.typing import Order
49+
from narwhals._arrow.typing import Order # type: ignore[attr-defined]
5050
from narwhals._arrow.typing import TieBreaker
5151
from narwhals._arrow.typing import _AsPyType
5252
from narwhals._arrow.typing import _BasicDataType
@@ -164,19 +164,19 @@ def __ne__(self: Self, other: object) -> Self: # type: ignore[override]
164164

165165
def __ge__(self: Self, other: Any) -> Self:
166166
ser, other = extract_native(self, other)
167-
return self._from_native_series(pc.greater_equal(ser, other)) # type: ignore[arg-type]
167+
return self._from_native_series(pc.greater_equal(ser, other))
168168

169169
def __gt__(self: Self, other: Any) -> Self:
170170
ser, other = extract_native(self, other)
171-
return self._from_native_series(pc.greater(ser, other)) # type: ignore[arg-type]
171+
return self._from_native_series(pc.greater(ser, other))
172172

173173
def __le__(self: Self, other: Any) -> Self:
174174
ser, other = extract_native(self, other)
175-
return self._from_native_series(pc.less_equal(ser, other)) # type: ignore[arg-type]
175+
return self._from_native_series(pc.less_equal(ser, other))
176176

177177
def __lt__(self: Self, other: Any) -> Self:
178178
ser, other = extract_native(self, other)
179-
return self._from_native_series(pc.less(ser, other)) # type: ignore[arg-type]
179+
return self._from_native_series(pc.less(ser, other))
180180

181181
def __and__(self: Self, other: Any) -> Self:
182182
ser, other = extract_native(self, other)
@@ -196,24 +196,24 @@ def __ror__(self: Self, other: Any) -> Self:
196196

197197
def __add__(self: Self, other: Any) -> Self:
198198
ser, other = extract_native(self, other)
199-
return self._from_native_series(pc.add(ser, other)) # type: ignore[arg-type]
199+
return self._from_native_series(pc.add(ser, other))
200200

201201
def __radd__(self: Self, other: Any) -> Self:
202-
return self + other # type: ignore[no-any-return]
202+
return self + other
203203

204204
def __sub__(self: Self, other: Any) -> Self:
205205
ser, other = extract_native(self, other)
206206
return self._from_native_series(pc.subtract(ser, other))
207207

208208
def __rsub__(self: Self, other: Any) -> Self:
209-
return (self - other) * (-1) # type: ignore[no-any-return]
209+
return (self - other) * (-1)
210210

211211
def __mul__(self: Self, other: Any) -> Self:
212212
ser, other = extract_native(self, other)
213213
return self._from_native_series(pc.multiply(ser, other))
214214

215215
def __rmul__(self: Self, other: Any) -> Self:
216-
return self * other # type: ignore[no-any-return]
216+
return self * other
217217

218218
def __pow__(self: Self, other: Any) -> Self:
219219
ser, other = extract_native(self, other)
@@ -381,10 +381,12 @@ def __narwhals_series__(self: Self) -> Self:
381381
def __getitem__(self: Self, idx: int) -> Any: ...
382382

383383
@overload
384-
def __getitem__(self: Self, idx: slice | Sequence[int] | pa.ChunkedArray) -> Self: ...
384+
def __getitem__(
385+
self: Self, idx: slice | Sequence[int] | ArrowChunkedArray
386+
) -> Self: ...
385387

386388
def __getitem__(
387-
self: Self, idx: int | slice | Sequence[int] | pa.ChunkedArray
389+
self: Self, idx: int | slice | Sequence[int] | ArrowChunkedArray
388390
) -> Any | Self:
389391
if isinstance(idx, int):
390392
return maybe_extract_py_scalar(
@@ -630,7 +632,7 @@ def sample(
630632
rng = np.random.default_rng(seed=seed)
631633
idx = np.arange(0, num_rows)
632634
mask = rng.choice(idx, size=n, replace=with_replacement)
633-
return self._from_native_series(ser.take(mask))
635+
return self._from_native_series(ser.take(mask)) # pyright: ignore[reportArgumentType]
634636

635637
def fill_null(
636638
self: Self,
@@ -690,7 +692,7 @@ def to_frame(self: Self) -> ArrowDataFrame:
690692
validate_column_names=False,
691693
)
692694

693-
def to_pandas(self: Self) -> pd.Series:
695+
def to_pandas(self: Self) -> pd.Series[Any]:
694696
import pandas as pd # ignore-banned-import()
695697

696698
return pd.Series(self._native_series, name=self.name) # pyright: ignore[reportArgumentType, reportCallIssue]

narwhals/_arrow/series_str.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import string
44
from typing import TYPE_CHECKING
5+
from typing import Any
56

67
import pyarrow.compute as pc
78

@@ -75,7 +76,7 @@ def to_datetime(self: Self, format: str | None) -> ArrowSeries: # noqa: A002
7576
native = self._compliant_series._native_series
7677
format = parse_datetime_format(native) if format is None else format
7778
strptime: Incomplete = pc.strptime
78-
timestamp_array: pa.Array[pa.TimestampScalar] = strptime(
79+
timestamp_array: pa.Array[pa.TimestampScalar[Any, Any]] = strptime(
7980
native, format=format, unit="us"
8081
)
8182
return self._compliant_series._from_native_series(timestamp_array)

narwhals/_arrow/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def narwhals_to_native_dtype(dtype: DType | type[DType], version: Version) -> pa
179179
if isinstance_or_issubclass(dtype, dtypes.Categorical):
180180
return pa.dictionary(pa.uint32(), pa.string())
181181
if isinstance_or_issubclass(dtype, dtypes.Datetime):
182-
return pa.timestamp(dtype.time_unit, tz=dtype.time_zone) # type: ignore[arg-type]
182+
return pa.timestamp(dtype.time_unit, tz=dtype.time_zone) # pyright: ignore[reportArgumentType]
183183
if isinstance_or_issubclass(dtype, dtypes.Duration):
184184
return pa.duration(dtype.time_unit)
185185
if isinstance_or_issubclass(dtype, dtypes.Date):
@@ -222,7 +222,7 @@ def extract_native(
222222
return lhs._native_series, lit(None, type=lhs._native_series.type)
223223

224224
if isinstance(rhs, ArrowDataFrame):
225-
return NotImplemented # type: ignore[no-any-return]
225+
return NotImplemented
226226

227227
if isinstance(rhs, ArrowSeries):
228228
if lhs._broadcast and not rhs._broadcast:

narwhals/_dask/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def func(df: DaskLazyFrame) -> list[dx.Series]:
108108
func,
109109
depth=0,
110110
function_name="col",
111-
evaluate_output_names=lambda _df: list(column_names),
111+
evaluate_output_names=lambda _df: column_names,
112112
alias_output_names=None,
113113
backend_version=backend_version,
114114
version=version,

narwhals/_duckdb/dataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def join(
282282
raise NotImplementedError(msg)
283283
rel = self._native_frame.set_alias("lhs").cross( # pragma: no cover
284284
other._native_frame.set_alias("rhs")
285-
) # type: ignore[operator]
285+
)
286286
else:
287287
# help mypy
288288
assert left_on is not None # noqa: S101

narwhals/_duckdb/expr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def func(_: DuckDBLazyFrame) -> list[duckdb.Expression]:
8787
return cls(
8888
func,
8989
function_name="col",
90-
evaluate_output_names=lambda _df: list(column_names),
90+
evaluate_output_names=lambda _df: column_names,
9191
alias_output_names=None,
9292
backend_version=backend_version,
9393
version=version,
@@ -403,7 +403,7 @@ def var(self: Self, ddof: int) -> Self:
403403
def _var(_input: duckdb.Expression) -> duckdb.Expression:
404404
n_samples = FunctionExpression("count", _input)
405405
# NOTE: Not implemented Error: Unable to transform python value of type '<class 'duckdb.duckdb.Expression'>' to DuckDB LogicalType
406-
return FunctionExpression("var_pop", _input) * n_samples / (n_samples - ddof) # type: ignore[operator]
406+
return FunctionExpression("var_pop", _input) * n_samples / (n_samples - ddof) # type: ignore[operator, no-any-return]
407407

408408
return self._from_call(_var, "var")
409409

narwhals/_duckdb/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ def narwhals_to_native_dtype(dtype: DType | type[DType], version: Version) -> st
161161
if isinstance_or_issubclass(dtype, dtypes.Date): # pragma: no cover
162162
return "DATE"
163163
if isinstance_or_issubclass(dtype, dtypes.List):
164-
inner = narwhals_to_native_dtype(dtype.inner, version) # type: ignore[union-attr]
164+
inner = narwhals_to_native_dtype(dtype.inner, version)
165165
return f"{inner}[]"
166166
if isinstance_or_issubclass(dtype, dtypes.Struct): # pragma: no cover
167167
inner = ", ".join(
168168
f'"{field.name}" {narwhals_to_native_dtype(field.dtype, version)}'
169-
for field in dtype.fields # type: ignore[union-attr]
169+
for field in dtype.fields
170170
)
171171
return f"STRUCT({inner})"
172172
if isinstance_or_issubclass(dtype, dtypes.Array): # pragma: no cover

narwhals/_expression_parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def infer_kind(obj: IntoExpr | _1DArray | object, *, str_as_lit: bool) -> ExprKi
476476

477477

478478
def apply_n_ary_operation(
479-
plx: CompliantNamespace,
479+
plx: CompliantNamespace[Any, Any],
480480
function: Any,
481481
*comparands: IntoExpr,
482482
str_as_lit: bool,

0 commit comments

Comments
 (0)