Comparisons to the singleton objects, like True, False, and None, should be done with identity, not equality. Use “is” or “is not”

Anti-pattern

if var != True:
    print("var is not equal to True")
if var == None:
    print("var is equal to None")

Best practice

if var is not True:
    print("var is not True")
if var is None:
    print("var is None")