Skip to content

Commit

Permalink
fix(python): ChainedWhen should not inherit Expr (#17142)
Browse files Browse the repository at this point in the history
Co-authored-by: Stijn de Gooijer <stijndegooijer@gmail.com>
  • Loading branch information
eitsupi and stinodego authored Jun 23, 2024
1 parent 232d557 commit 6f3c68b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion py-polars/polars/expr/whenthen.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def otherwise(self, statement: IntoExpr) -> Expr:
return wrap_expr(self._then.otherwise(statement_pyexpr))


class ChainedWhen(Expr):
class ChainedWhen:
"""
Utility class for the `when-then-otherwise` expression.
Expand Down
8 changes: 8 additions & 0 deletions py-polars/tests/unit/functions/test_when_then.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,3 +622,11 @@ def test_when_then_supertype_15975_comment() -> None:
)

assert q.collect()["val"].to_list() == [1.0, 1.5, 16.0]


def test_chained_when_no_subclass_17142() -> None:
# https://github.com/pola-rs/polars/pull/17142
when = pl.when(True).then(1).when(True)

assert not isinstance(when, pl.Expr)
assert "<polars.expr.whenthen.ChainedWhen object at" in str(when)

0 comments on commit 6f3c68b

Please sign in to comment.