no-static-if-condition

Discourages if conditions which evaluate to a static value (e.g. or True, and False, etc).

Message

Your if condition appears to evaluate to a static value (e.g. or True, and False). Please double check this logic and if it is actually temporary debug code.

Valid examples

if my_func() or not else_func():
    pass
if function_call(True):
    pass
Show more
# ew who would this???
def true():
    return False
if true() and else_call():  # True or False
    pass
# ew who would this???
if False or some_func():
    pass

Invalid examples

if True:
    do_something()
if crazy_expression or True:
    do_something()
if crazy_expression and False:
    do_something()
Show more
if crazy_expression and not True:
    do_something()
if crazy_expression or not False:
    do_something()
if crazy_expression or (something() or True):
    do_something()
if crazy_expression and (something() and (not True)):
    do_something()
if crazy_expression and (something() and (other_func() and not True)):
    do_something()
if (crazy_expression and (something() and (not True))) or True:
    do_something()
async def some_func() -> none:
    if (await expression()) and False:
        pass