From 46793802a0e99db070ca9da68531fd52e0a4e49f Mon Sep 17 00:00:00 2001 From: Jack Xu Date: Sun, 3 Nov 2024 17:45:31 -0500 Subject: [PATCH] remove kwargs in collect method --- py-polars/polars/lazyframe/frame.py | 6 +++--- py-polars/tests/unit/lazyframe/test_lazyframe.py | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py index d5c56c93ca0a..b505e6096d4a 100644 --- a/py-polars/polars/lazyframe/frame.py +++ b/py-polars/polars/lazyframe/frame.py @@ -1830,10 +1830,11 @@ def collect( collapse_joins: bool = True, no_optimization: bool = False, streaming: bool = False, + new_streaming: bool = False, engine: EngineType = "cpu", background: bool = False, _eager: bool = False, - **_kwargs: Any, + post_opt_callback: Callable[..., Any] | None = None, ) -> DataFrame | InProcessQuery: """ Materialize this LazyFrame into a DataFrame. @@ -1982,7 +1983,6 @@ def collect( │ c ┆ 6 ┆ 1 │ └─────┴─────┴─────┘ """ - new_streaming = _kwargs.get("new_streaming", False) if no_optimization or _eager: predicate_pushdown = False @@ -2046,7 +2046,7 @@ def collect( engine = GPUEngine() callback = partial(cudf_polars.execute_with_cudf, config=engine) # Only for testing purposes - callback = _kwargs.get("post_opt_callback", callback) + callback = post_opt_callback or callback return wrap_df(ldf.collect(callback)) @overload diff --git a/py-polars/tests/unit/lazyframe/test_lazyframe.py b/py-polars/tests/unit/lazyframe/test_lazyframe.py index fbc9b5e1ae30..0992c91976d4 100644 --- a/py-polars/tests/unit/lazyframe/test_lazyframe.py +++ b/py-polars/tests/unit/lazyframe/test_lazyframe.py @@ -907,6 +907,11 @@ def test_collect_all(df: pl.DataFrame, no_optimization: bool) -> None: assert cast(float, out[1].item()) == 12.0 +def test_collect_unexpected_kwargs(df: pl.DataFrame) -> None: + with pytest.raises(TypeError, match="unexpected keyword argument"): + df.lazy().collect(common_subexpr_elim=False) + + def test_spearman_corr() -> None: ldf = pl.LazyFrame( {