polars/polars-null-comparison
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Polars | warning | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
Polars 2.1.0 emits UserWarning for comparison to None. Use is_null to test for nulls.
expr == Noneexpr.is_null()What the rule reports
Section titled “What the rule reports”| Form | Replacement example | Proof on 2.1.0 |
|---|---|---|
expr == None |
expr.is_null() |
UserWarning under -W error |
expr != None |
expr.is_not_null() |
UserWarning under -W error |
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to apply the offered rewrite after checking the intended result.
Diagnostic message
Section titled “Diagnostic message”Polars 2.1.0 emits UserWarning for comparison to None. Use is_null to test for nulls.See all rules in the Polars pack.