A function returns tuples of different lengths on different paths, so unpacking its result fails on some of them
What it finds
Callers unpack a returned tuple into a fixed number of names; when one return gives two items and another three, a, b = f() raises ValueError on some paths only. Checked are return statements whose value is a tuple display without *; empty tuples are left alone.
From the rule's source, returned_tuple_lengths_differ.rs.
def split(x): if x: return 1, 2 return 1, 2, 3tx0 reports: this returns 3 items where another return gives 2 def same(x): if x: return 1, 2 return 3, 4 Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:returned-tuple-lengths-differ" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:returned-tuple-lengths-differ] reason="..."tx0 explain tx0/python:returned-tuple-lengths-differ shows the same in the terminal. Found a false positive? Report it.