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:
good: str = "good"
# 2:
good: str = f"with_arg{arg}"
# 3:
good = "good{arg1}".format(1234)
# 4:
good = "good".format()
# 5:
good = "good" % {}
# 6:
good = "good" % ()
# 7:
good = rf"good +{bar}"
INVALID Code Examples
# 1:
bad: str = f"bad" + "bad"
Autofix:
---
+++
@@ -1 +1 @@
-bad: str = f"bad" + "bad"
+bad: str = "bad" + "bad"
# 2:
bad: str = f'bad'
Autofix:
---
+++
@@ -1 +1 @@
-bad: str = f'bad'
+bad: str = 'bad'
# 3:
bad: str = rf'bad +'
Autofix:
---
+++
@@ -1 +1 @@
-bad: str = rf'bad +'
+bad: str = r'bad +'
# 4:
bad: str = f"no args but messing up {{ braces }}"
Autofix:
---
+++
@@ -1 +1 @@
-bad: str = f"no args but messing up {{ braces }}"
+bad: str = "no args but messing up { braces }"