-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUF010 auto-fix only once per line #4567
Comments
I’m wondering if we should allow overlapping fixes to be output in diff mode. |
I think that, as a user, something seems wrong when running without |
It would be possible fix this if the range for f"{str(bla)}, {repr(bla)}, {ascii(bla)}"
|
Yeah, I looked at this briefly, but there isn't really a straightforward way to fix this right now. |
Could you explain why the range is incorrect? |
A node's range should enclose all its content but not more. E.g. it should be impossible for siblings to have an overlapping range as it is the case here for the
I have to take a look at RustPython on why it ends up with these ranges but this might be a problem for the formatter too. |
This was actually just a bug in the rule. |
With 6db05d8, output of
--show-fixes
:cargo run -p ruff_cli -- check crates/ruff/resources/test/fixtures/ruff/RUF010.py --no-cache --select RUF010 --show-source --show-fixes
But, actual fixes are only one per line, this is the output of
--diff
:cargo run -p ruff_cli -- check crates/ruff/resources/test/fixtures/ruff/RUF010.py --no-cache --select RUF010 --diff
Note that reverting #4524 seems to fix the issue.
I'm guessing the issue is that these fixes are now considered overlapping in
crates/ruff/src/autofix/mod.rs:53,60
though I'm not sure how to fix this. Best idea I could think of is moving the next fixes range by the difference of char count from the last fix (as long as they don't overlap in the first place)Maybe it would be good to add snapshot tests for
--diff
?The text was updated successfully, but these errors were encountered: