-
Notifications
You must be signed in to change notification settings - Fork 2k
SIM222: false positive on format strings #9479
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Consider this script:
repro.py
def foo(a: str, b: str) -> None:
print(f"{a}{b}" or "bar")
if __name__ == "__main__":
foo("Hello ", "World")
foo("", "")When run, it prints:
❯ python repro.py
Hello World
bar
So apparently, f"{a}{b}" is not a truthy constant! And yet:
❯ ruff --version
ruff 0.1.11
❯ ruff check --isolated --select=SIM repro.py
repro.py:2:11: SIM222 Use `f"{a}{b}"` instead of `f"{a}{b}" or ...`
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).FWIW, SonarLint's python:S5797 triggers as well.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working