diff --git a/narwhals/_dask/dataframe.py b/narwhals/_dask/dataframe.py index d493a96313..f1ec3b6e31 100644 --- a/narwhals/_dask/dataframe.py +++ b/narwhals/_dask/dataframe.py @@ -372,11 +372,11 @@ def group_by(self, *by: str, drop_null_keys: bool) -> DaskLazyGroupBy: return DaskLazyGroupBy(self, list(by), drop_null_keys=drop_null_keys) - def tail(self: Self, n: int) -> Self: + def tail(self: Self, n: int) -> Self: # pragma: no cover native_frame = self._native_frame n_partitions = native_frame.npartitions - if n_partitions == 1: # pragma: no cover + if n_partitions == 1: return self._from_native_frame(self._native_frame.tail(n=n, compute=False)) else: msg = "`LazyFrame.tail` is not supported for Dask backend with multiple partitions." diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py index 93cd7d7476..385a5de050 100644 --- a/narwhals/dataframe.py +++ b/narwhals/dataframe.py @@ -4360,7 +4360,7 @@ def head(self, n: int = 5) -> Self: """ return super().head(n) - def tail(self, n: int = 5) -> Self: + def tail(self, n: int = 5) -> Self: # pragma: no cover r"""Get the last `n` rows. !!! warning diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py index ce090982c5..f61a382649 100644 --- a/narwhals/stable/v1/__init__.py +++ b/narwhals/stable/v1/__init__.py @@ -934,7 +934,7 @@ def unique(self, *, maintain_order: bool | None = None) -> Self: Returns: A new expression. """ - if maintain_order: + if maintain_order: # pragma: no cover msg = "`maintain_order=True` is not supported for Expr.unique." raise ValueError(msg) if maintain_order is not None: diff --git a/tests/expr_and_series/unique_test.py b/tests/expr_and_series/unique_test.py index b2877c646d..7379d6ccdd 100644 --- a/tests/expr_and_series/unique_test.py +++ b/tests/expr_and_series/unique_test.py @@ -5,6 +5,7 @@ import pytest import narwhals as nw +import narwhals.stable.v1 as nw_v1 from narwhals.exceptions import LengthChangingExprError from tests.utils import Constructor from tests.utils import ConstructorEager @@ -26,6 +27,9 @@ def test_unique_expr(constructor: Constructor) -> None: expected = {"a": [1, 2]} assert_equal_data(result, expected) + with pytest.warns(UserWarning): + df.select(nw_v1.col("a").unique(maintain_order=False).sum()) + def test_unique_expr_agg( constructor: Constructor, request: pytest.FixtureRequest