not or ~ is applied twice in a row
What it finds
not not x, ~~mask: the two operators cancel out, except that not not x turns x into a bool, which bool(x) says more plainly. A doubled operator is often a typo.
From the rule's source, double_negation.rs.
def flags(x, mask): a = not not xtx0 reports: not not cancels out; bool(...) says the same more plainly b = ~~masktx0 reports: ~~ cancels out and leaves the value as it was c = not (not x)tx0 reports: not not cancels out return a, b, c, not x, -(-mask) 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:double-negation" = "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:double-negation] reason="..."tx0 explain tx0/python:double-negation shows the same in the terminal. Found a false positive? Report it.