The result of len is tested for being negative, which it never is
What it finds
len(items) < 0, len(items) >= 0: a length is never negative, so the first is always false and the second always true. The test was likely meant as == 0 or > 0.
From the rule's source, length_sign_test.rs.
def check(items, n): if len(items) < 0:tx0 reports: len(items) < 0 is always false, since a length is never negative return None if 0 <= len(items):tx0 reports: is always true, since a length is never negative return items if len(items) > 0 or len(items) == 0 or n < 0: return n Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/python:length-sign-test" = "off"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:length-sign-test] reason="..."tx0 explain tx0/python:length-sign-test shows the same in the terminal. Found a false positive? Report it.