FURB116 has false positives and unsafe fixes #16472
Labels
bug
Something isn't working
fixes
Related to suggested fixes for violations
help wanted
Contributions especially welcome
Summary
The fix for f-string-number-format (FURB116) only works on non-negative integers. If the argument isn’t an
int
orbool
literal (or a variable that was set to one of those, or any other expression that Ruff can prove is a non-negative integer), the rule should be marked unsafe. The fix can also introduce a syntax error for certain complex expressions that the rule was probably not intended to handle.The fix changes behavior for negative integers.
FURB116 applies to all number literals, but
float
andcomplex
literals are false positives which the rule should ignore.In general, the fix should be marked unsafe, except when it can be proved to be safe. Otherwise, the fix changes behavior, sometimes by changing the error type as in the previous example, and sometimes by changing behavior in other ways.
The fix introduces a syntax error when the argument begins with a brace.
The fix introduces a syntax error in Python 3.11 and earlier when the argument contains the same kind of quotation marks as the fix’s f-string.
The fix introduces a syntax error in Python 3.11 and earlier when the argument contains a backslash.
The fix introduces a syntax error in Python 3.11 and earlier when the argument spans multiple lines.
Version
ruff 0.9.9 (091d0af 2025-02-28)
The text was updated successfully, but these errors were encountered: