The SIM208 rule should be updated to only emit errors for not not x in boolean contexts, since changing it to just x can cause different results under certain circumstances.
Example
x = 123
y = not not x
In the above example, y is True, but changing it to y = x turns it into 123.
Solution
Only check when in a boolean context, such as an if/while clause:
x = ... # dont check here
if x: # ok to check
...
elif x: # and here
...
elif f(x): # but not here!
...
The
SIM208
rule should be updated to only emit errors fornot not x
in boolean contexts, since changing it to justx
can cause different results under certain circumstances.Example
In the above example,
y
isTrue
, but changing it toy = x
turns it into123
.Solution
Only check when in a boolean context, such as an
if
/while
clause: