polars/polars-null-comparison
| Rule | polars-null-comparison |
|---|---|
| Pack | Polars |
| Severity | warning |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | every version |
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.
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 emits UserWarning for comparison to None. Use is_null to test for nulls.Browse the other rules of the Polars pack.