Summary
Some unnecessarily wrapped literals would be easy for native-literals (UP018) to detect but are not detected.
int() is not detected when followed by an attribute. This is to avoid a syntax error. However, the syntax error can be avoided with parentheses. Compare int(0), which UP018 always detects, inserting parentheses when needed.
Implicitly concatenated string literals are skipped for no apparent reason. If it spans multiple lines, it still needs to be parenthesized, but the str call is unnecessary.
The object keyword of str is not supported.
complex is not supported.
Example:
$ cat >up018.py <<'# EOF'
int().denominator
str("A" "B")
str(
"A"
"B"
)
str(object="!")
complex(1j)
complex(real=1j)
# EOF
$ ruff --isolated check up018.py --select UP018
All checks passed!
Ideal fixed output:
(0).denominator
"A" "B"
(
"A"
"B"
)
"!"
1j
1j
Version
ruff 0.12.8 (f51a228 2025-08-07)
Summary
Some unnecessarily wrapped literals would be easy for
native-literals(UP018) to detect but are not detected.int()is not detected when followed by an attribute. This is to avoid a syntax error. However, the syntax error can be avoided with parentheses. Compareint(0), which UP018 always detects, inserting parentheses when needed.Implicitly concatenated string literals are skipped for no apparent reason. If it spans multiple lines, it still needs to be parenthesized, but the
strcall is unnecessary.The
objectkeyword ofstris not supported.complexis not supported.Example:
Ideal fixed output:
Version
ruff 0.12.8 (f51a228 2025-08-07)