FURB105 fix removes `sep` arguments with side effects
dscorbett opened this issue · 1 comments
The fix for FURB105 removes unneeded sep
arguments even when they might have side effects. In that case, the fix should be omitted or marked unsafe.
$ ruff --version
ruff 0.6.2
$ cat furb105.py
print(sep=print("sep"))
$ python furb105.py
sep
$ ruff check --isolated --select FURB105 furb105.py --fix
Found 1 error (1 fixed, 0 remaining).
$ cat furb105.py
print()
$ python furb105.py
I'd be happy to accept a PR that marked the fix as unsafe if we detected the argument to sep=
as something that could have a side effect. We could use the contains_effect
function we have here for that purpose:
However, I think we should still offer the fix (though it'll be marked as unsafe), even in these situations. I think it'll honestly be relatively rare for somebody to pass in a function that has a side effect to sep=
here, and contains_effect()
errs on the side of assuming that arbitrary functions might have side effects, although in reality they often won't.