Skip to content

Commit c5500a3

Browse files
committed
chore: Make PolarsNamespace.concat compliant
Adding the annotation of `CompliantNamespace` revealed a lot of gaps
1 parent 1591c2d commit c5500a3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

narwhals/_polars/namespace.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Any
66
from typing import Iterable
77
from typing import Literal
8-
from typing import Sequence
98
from typing import overload
109

1110
import polars as pl
@@ -77,38 +76,36 @@ def len(self: Self) -> PolarsExpr:
7776
@overload
7877
def concat(
7978
self: Self,
80-
items: Sequence[PolarsDataFrame],
79+
items: Iterable[PolarsDataFrame],
8180
*,
8281
how: Literal["vertical", "horizontal", "diagonal"],
8382
) -> PolarsDataFrame: ...
8483

8584
@overload
8685
def concat(
8786
self: Self,
88-
items: Sequence[PolarsLazyFrame],
87+
items: Iterable[PolarsLazyFrame],
8988
*,
9089
how: Literal["vertical", "horizontal", "diagonal"],
9190
) -> PolarsLazyFrame: ...
9291

9392
def concat(
9493
self: Self,
95-
items: Sequence[PolarsDataFrame] | Sequence[PolarsLazyFrame],
94+
items: Iterable[PolarsDataFrame] | Iterable[PolarsLazyFrame],
9695
*,
9796
how: Literal["vertical", "horizontal", "diagonal"],
9897
) -> PolarsDataFrame | PolarsLazyFrame:
9998
from narwhals._polars.dataframe import PolarsDataFrame
10099
from narwhals._polars.dataframe import PolarsLazyFrame
101100

102-
dfs: list[Any] = [item._native_frame for item in items]
101+
dfs: Iterable[Any] = (item.native for item in items)
103102
result = pl.concat(dfs, how=how)
104103
if isinstance(result, pl.DataFrame):
105104
return PolarsDataFrame(
106-
result,
107-
backend_version=items[0]._backend_version,
108-
version=items[0]._version,
105+
result, backend_version=self._backend_version, version=self._version
109106
)
110107
return PolarsLazyFrame(
111-
result, backend_version=items[0]._backend_version, version=items[0]._version
108+
result, backend_version=self._backend_version, version=self._version
112109
)
113110

114111
def lit(self: Self, value: Any, dtype: DType | None) -> PolarsExpr:

0 commit comments

Comments
 (0)