.. _NoRedundantFStringRule:

======================
NoRedundantFStringRule
======================

Remove redundant f-string without placeholders.

-------
Message
-------
f-string doesn't have placeholders, remove redundant f-string.

----------------
Has Autofix: Yes
----------------

-------------------
VALID Code Examples
-------------------

# 1:







.. code-block:: python

            good: str = "good"




# 2:







.. code-block:: python

            good: str = f"with_arg{arg}"




# 3:







.. code-block:: python

            good = "good{arg1}".format(1234)




.. container:: toggle


    # 4:







    .. code-block:: python

                good = "good".format()





    # 5:







    .. code-block:: python

                good = "good" % {}





    # 6:







    .. code-block:: python

                good = "good" % ()





    # 7:







    .. code-block:: python

                good = rf"good	+{bar}"





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

# 1:







.. code-block:: python

            bad: str = f"bad" + "bad"




Autofix:

.. code-block:: python

    --- 
    +++ 
    @@ -1 +1 @@
    -bad: str = f"bad" + "bad"
    +bad: str = "bad" + "bad"

# 2:







.. code-block:: python

            bad: str = f'bad'




Autofix:

.. code-block:: python

    --- 
    +++ 
    @@ -1 +1 @@
    -bad: str = f'bad'
    +bad: str = 'bad'

# 3:







.. code-block:: python

            bad: str = rf'bad	+'




Autofix:

.. code-block:: python

    --- 
    +++ 
    @@ -1 +1 @@
    -bad: str = rf'bad	+'
    +bad: str = r'bad	+'

.. container:: toggle


    # 4:







    .. code-block:: python

                bad: str = f"no args but messing up {{ braces }}"




    Autofix:

    .. code-block:: python

        --- 
        +++ 
        @@ -1 +1 @@
        -bad: str = f"no args but messing up {{ braces }}"
        +bad: str = "no args but messing up { braces }"

