reversed(sorted(x)) sorts and then walks backwards, where sorted(x, reverse=True) gives the list in that order
What it finds
sorted(..., reverse=True) gives the descending order directly as a list, and keeps equal elements in their original order, which reversed(sorted(...)) does not.
From the rule's source, reversed_sorted.rs.
def order(xs): a = reversed(sorted(xs))tx0 reports: sorted(..., reverse=True) gives this order directly b = sorted(xs, reverse=True) c = reversed(xs) return a, b, c 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:reversed-sorted" = "note"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:reversed-sorted] reason="..."tx0 explain tx0/python:reversed-sorted shows the same in the terminal. Found a false positive? Report it.