An item or attribute is assigned and then assigned again by the next statement, so the first value is lost
What it finds
Two assignments in a row to the same d[key] or obj.attr, where the second does not read the first, leave only the second value. One of the targets usually has a wrong key or name.
From the rule's source, overwritten_item.rs.
def fill(config, obj): config["mode"] = "fast" config["mode"] = "slow"tx0 reports: this overwrites the value the previous statement just assigned obj.size = 1 obj.size = obj.size + 1 config["a"] = 1 config["b"] = 2 Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:overwritten-item" = "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:overwritten-item] reason="..."tx0 explain tx0/python:overwritten-item shows the same in the terminal. Found a false positive? Report it.