Skip to content

Commit

Permalink
fix(python): Replace _kwargs in collect method (#19618)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackxxu authored Nov 16, 2024
1 parent 5476332 commit 7817fcf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,14 @@ def collect(
│ c ┆ 6 ┆ 1 │
└─────┴─────┴─────┘
"""
for k in _kwargs:
if k not in ( # except "private" kwargs
"new_streaming",
"post_opt_callback",
):
error_msg = f"collect() got an unexpected keyword argument '{k}'"
raise TypeError(error_msg)

new_streaming = _kwargs.get("new_streaming", False)

if no_optimization or _eager:
Expand Down
5 changes: 5 additions & 0 deletions py-polars/tests/unit/lazyframe/test_lazyframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) # type: ignore[call-overload]


def test_spearman_corr() -> None:
ldf = pl.LazyFrame(
{
Expand Down

0 comments on commit 7817fcf

Please sign in to comment.