-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
Summary
The fix for redundant-log-base (FURB163) should be marked unsafe when it switches the function to log2 or log10, because that can change behavior. It can also change behavior when the first argument is starred. It should also be marked unsafe when it deletes comments.
Floating-point vagaries:
$ cat >furb163_1.py <<'# EOF'
import math
print(math.log(4.13e223, 2))
print(math.log(4.14e223, 10))
# EOF
$ python furb163_1.py
742.8361069415266
223.61700034112087
$ ruff --isolated check furb163_1.py --select FURB163 --fix
Found 2 errors (2 fixed, 0 remaining).
$ python furb163_1.py
742.8361069415265
223.6170003411209Starred arguments:
$ cat >furb163_2.py <<'# EOF'
import math
def print_log(*args):
try:
print(math.log(*args, math.e))
except TypeError as e:
print(repr(e))
print_log()
print_log(100, 10)
# EOF
$ python furb163_2.py
1.0
TypeError('log expected at most 2 arguments, got 3')
$ ruff --isolated check furb163_2.py --select FURB163 --fix
Found 1 error (1 fixed, 0 remaining).
$ python furb163_2.py
TypeError('log expected at least 1 argument, got 0')
2.0Deleted comments:
$ cat >furb163_3.py <<'# EOF'
import math
print(math.log(
3, # This is the argument...
math.e, # ... and this is the base.
))
# EOF
$ ruff --isolated check furb163_3.py --select FURB163 --fix
Found 1 error (1 fixed, 0 remaining).
$ cat furb163_3.py
import math
print(math.log(3))Version
ruff 0.11.13 (5faf72a 2025-06-05)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome