Closed eli-schwartz closed 10 months ago
Thanks for proxying this bugreport; I can confirm I saw this behavior when trialing ruff on the ironic-python-agent codebase.
If ruff isn't confident it can apply the UP015 fixer it should just refuse to do it at all without --unsafe-fixes, of course. Either solution is valid, though I suspect users would be okay with just removing the 'r'
anyways.
The ideal behavior here is for us to re-format the fix, but in lieu of that, I don't know that not offering the fix is actually better -- we've had a lot of confusion in the past when adding that behavior to specific rules (it's respected in some cases): https://github.com/astral-sh/ruff/issues/8106
Maybe there needs to be:
1) a generic mechanism for autofixes to detect when they would rewrite code which formerly obeyed the line-length setting, to violate it, and mark that autofix as long-line-unsafe
2) a dedicated option, similar to --unsafe-fixes but not actually called unsafe-fixes, e.g. --long-line-fixes
I definitely do not think it's appropriate to violate the line length.
ruff check --fix
and get fewer fixes, but passing CII'm going to merge this into https://github.com/astral-sh/ruff/issues/8106 and make the issue more general -- bear with me...
Ruff is responsible for reformatting this line when applying lint fixes. It should respect the max line length, and avoid folding the two lines together as a side effect of removing the open mode.