New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect useless f-strings #9530
Comments
+1 from me. It also seems relatively immune to false positive and simple without looking too much into it. How would you name it ? |
@Pierre-Sassoulas I would call |
class SneakyString(str):
def __str__(self) -> str:
return "Different string"
x = SneakyString("A")
print(f"{x}" + "B")
print(f"{x:.2}" + "B")
print(x + "B") I think there is a actually a pretty high chance for false positives as the logic for f-strings is quite difficult to statically imitate. |
Not sure what the false positive is in this case @DanielNoord ? Isn't |
The false positive is that |
|
Right. Still + 0.5 on this, but it's less useful if it become |
Current problem
Real diff:
This is an example where Pylint could identify codestyle problem. Useless f-string. i.e. f-strings containing single variable without formatting attributes and without other f-string parts.
Desired solution
Detect such cases and notify
Additional context
No response
The text was updated successfully, but these errors were encountered: