-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
previewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
logging-eager-conversion (RUF065) applies when a value is doubly converted with %r and repr. It should only apply to single conversions. Example:
$ cat >ruf065.py <<'# EOF'
import logging
logging.warning("%r", repr("1\n2"))
# EOF
$ python3.14 ruf065.py
WARNING:root:"'1\\n2'"
$ ruff --isolated check ruf065.py --select RUF065 --preview --output-format concise -q
ruf065.py:2:23: RUF065 Unnecessary `repr()` conversion when formatting with `%r`Removing repr, as the rule suggests, changes the program’s behavior:
$ cat >ruf065_fixed.py <<'# EOF'
import logging
logging.warning("%r", "1\n2")
# EOF
$ python3.14 ruf065_fixed.py
WARNING:root:'1\n2'The combinations that are currently supported and that would be appropriate to support (not that it’s required, but you might want to) are:
| Code | Function | Currently supported | Appropriate to support | Replacement code |
|---|---|---|---|---|
%s |
str |
✅ Yes | ✅ Yes | %s |
%r |
repr |
✅ Yes | ❌ No | N/A |
%s |
repr |
❌ No | ✅ Yes | %r |
%s |
ascii |
❌ No | ✅ Yes | %a |
%s |
oct |
❌ No | ✅ Yes | %#o |
%s |
hex |
❌ No | ✅ Yes | %#x |
Version
ruff 0.13.2 (b0bdf03 2025-09-25)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
previewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule