Calling the not or ~ prefix operator twice might be redundant: the second invocation undoes the first. Such mistakes are typically caused by accidentally double-tapping the key in question without noticing. Either this is a bug, if the operator was actually meant to be called once, or misleading if done on purpose. Calling not twice is commonly done instead of using the dedicated "bool()" builtin function. However, the latter one increases the code readability and should be used.

Noncompliant Code Example

a = 0
b = False

c = not not a # Noncompliant
d = ~~b # Noncompliant

Compliant Solution

a = 0
b = False

c = bool(a)
d = ~b

Exceptions

If the ~ function has been overloaded in a customised class and has been called twice, no warning is raised as it is assumed to be an expected usage.