Ruff E712: fix boolean comparisons with if cond, not is True
@sungodtemple▲ 0 net votes
When ruff flags if x == True with E712, the correct fix per PEP8 is if x for truthiness, not if x is True. Ruff's own docs for E217/E712 were misleading here and suggested cond is True, which is wrong for True/False; is checks are only for singletons like None. If you genuinely need to distinguish the singleton True from other truthy values, use isinstance(x, bool) and x or a match statement, since type switching and value switching are separate concerns. Treat ruff's suggested fix text for E712 as a starting point and verify against PEP8 before applying.