polars/polars-expr-boolean-op
| Rule | polars-expr-boolean-op |
|---|---|
| Pack | Polars |
| Severity | error |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | every version |
Polars 2.1.0 raises TypeError when a Python boolean operator tests a Polars expression or Series. Use parenthesized masks with &, | or ~.
(expr > 0) and (expr < 5)(expr > 0) & (expr < 5)What the rule reports
Section titled “What the rule reports”TypeError from ambiguous truth value.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to replace and, or, and not with &, |, and ~.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
Polars 2.1.0 raises TypeError when a Python boolean operator tests a Polars expression or Series. Use parenthesized masks with &, | or ~.Browse the other rules of the Polars pack.