A value is looked up with in in an empty display
What it finds
if key in []:, x not in (): nothing is a member of an empty list, tuple or dict, so in is always false and not in always true. The collection was probably meant to hold something, or the test to go elsewhere.
From the rule's source, empty_membership.rs.
def check(key, value): if key in []:tx0 reports: nothing is in [], so this test is always false return 1 if value not in ():tx0 reports: nothing is in (), so this test is always true return 2 if key in {}:tx0 reports: nothing is in {} return 3 if key in [1] or key in ("a",): return 4 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:empty-membership" = "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:empty-membership] reason="..."tx0 explain tx0/python:empty-membership shows the same in the terminal. Found a false positive? Report it.