NoStaticIfConditionRule

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.

Has Autofix: No

VALID Code Examples

# 1:

if my_func() or not else_func():
    pass

# 2:

if function_call(True):
    pass

# 3:

# ew who would this???
def true():
    return False
if true() and else_call():  # True or False
    pass

# 4:

# ew who would this???
if False or some_func():
    pass

INVALID Code Examples

# 1:

if True:
    do_something()

# 2:

if crazy_expression or True:
    do_something()

# 3:

if crazy_expression and False:
    do_something()

# 4:

if crazy_expression and not True:
    do_something()

# 5:

if crazy_expression or not False:
    do_something()

# 6:

if crazy_expression or (something() or True):
    do_something()

# 7:

if crazy_expression and (something() and (not True)):
    do_something()

# 8:

if crazy_expression and (something() and (other_func() and not True)):
    do_something()

# 9:

if (crazy_expression and (something() and (not True))) or True:
    do_something()

# 10:

async def some_func() -> none:
    if (await expression()) and False:
        pass