polars/polars-list-get-oob
| Rule | polars-list-get-oob |
|---|---|
| Pack | Polars |
| Severity | info |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | every version |
Polars raises ComputeError for an out-of-bounds list offset by default. Pass null_on_oob=True when shorter lists are expected.
pl.Series([[1], [2, 3]]).list.get(1)pl.Series([[1], [2, 3]]).list.get(1, null_on_oob=True)What the rule reports
Section titled “What the rule reports”Index 1 raised ComputeError for a one-item list. null_on_oob=True returned [None, 3].
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to add null_on_oob=True to the list.get call.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
Polars raises ComputeError for an out-of-bounds list offset by default. Pass null_on_oob=True when shorter lists are expected.Browse the other rules of the Polars pack.