A set display lists the same member twice
What it finds
{"read", "write", "read"}: a set keeps one of equal members, so the second is lost. It was usually meant to be another value.
Compared are members written as literals, names and attribute chains, by their tokens, and strings by their value, so 'a' and "a" are the same.
From the rule's source, duplicate_set_item.rs.
def modes(x, y): a = {'read', 'write', 'read'}tx0 reports: 'read' is already in this set b = {x.mode, y, x.mode}tx0 reports: x.mode is already in this set c = {1, 2, 3} d = {'a', "a"}tx0 reports: is already in this set e = {f(), f()} return a, b, c, d, e 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:duplicate-set-item" = "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:duplicate-set-item] reason="..."tx0 explain tx0/python:duplicate-set-item shows the same in the terminal. Found a false positive? Report it.