.. _NoStaticIfConditionRule:

=======================
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:







.. code-block:: python


    if my_func() or not else_func():
        pass





# 2:







.. code-block:: python


    if function_call(True):
        pass





# 3:







.. code-block:: python


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





.. container:: toggle


    # 4:







    .. code-block:: python


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






---------------------
INVALID Code Examples
---------------------

# 1:







.. code-block:: python


    if True:
        do_something()





# 2:







.. code-block:: python


    if crazy_expression or True:
        do_something()





# 3:







.. code-block:: python


    if crazy_expression and False:
        do_something()





.. container:: toggle


    # 4:







    .. code-block:: python


        if crazy_expression and not True:
            do_something()






    # 5:







    .. code-block:: python


        if crazy_expression or not False:
            do_something()






    # 6:







    .. code-block:: python


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






    # 7:







    .. code-block:: python


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






    # 8:







    .. code-block:: python


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






    # 9:







    .. code-block:: python


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






    # 10:







    .. code-block:: python


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





