A value is compared with True or False using == or !=

tx0/python:bool-literal-comparisonstrictnotestyle

What it finds

if done == True: adds a comparison to what if done: already tests, and flag != False says flag the long way. For values that are not bool the two differ: 1 == True holds but 2 == True does not, so write what is meant, the value itself, its negation with not, or is True where only the object True counts.

From the rule's source, bool_literal_comparison.rs.

Example from the rule's tests
def check(done, flag):    if done == True:tx0 reports: comparing with True restates the truth test        return 1    if flag != False:tx0 reports: comparing with False restates the truth test        return 2    return done is True or done == 1
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

tx0.toml
[rules]
"tx0/python:bool-literal-comparison" = "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:bool-literal-comparison] reason="..."

tx0 explain tx0/python:bool-literal-comparison shows the same in the terminal. Found a false positive? Report it.