-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingpreviewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
logging-eager-conversion (RUF065) should only treat str as an unnecessary conversion when it has exactly one argument and that argument isn’t starred. Otherwise, the str call is doing something else and can’t be so straightforwardly removed. Example:
$ cat >ruf065.py <<'# EOF'
import logging
logging.warning("%s", str())
logging.warning("%s", str(b"\xe2\x9a\xa0", "utf-8"))
logging.warning("%s", str(*(b"\xf0\x9f\x9a\xa7", "utf-8")))
logging.warning("%s", str(**{"object": b"\xf0\x9f\x9a\xa8", "encoding": "utf-8"}))
# EOF
$ ruff --isolated check ruf065.py --select RUF065 --preview --output-format concise -q
ruf065.py:2:23: RUF065 Unnecessary `str()` conversion when formatting with `%s`
ruf065.py:3:23: RUF065 Unnecessary `str()` conversion when formatting with `%s`
ruf065.py:4:23: RUF065 Unnecessary `str()` conversion when formatting with `%s`
ruf065.py:5:23: RUF065 Unnecessary `str()` conversion when formatting with `%s`Version
ruff 0.14.4 (c7ff982 2025-11-06)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpreviewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule