Several append calls on the same list follow each other, where one extend or a display does the same
What it finds
items.append(a) followed by items.append(b) and more calls on the same list can be one items.extend((a, b)), or part of the display that made the list. Reported is the first of three or more consecutive statements that each call append on the same name or attribute with one argument.
From the rule's source, consecutive_appends.rs.
def build(a, b, c): items = [] items.append(a)tx0 reports: 3 append calls on items in a row items.append(b) items.append(c) other = [] other.append(a) other.append(b) return items, other 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:consecutive-appends" = "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:consecutive-appends] reason="..."tx0 explain tx0/python:consecutive-appends shows the same in the terminal. Found a false positive? Report it.