-
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
RUF100
should probably delete an entire comment noqa
is part of
#12251
Comments
I'm unsure -- I think the current behavior is intentional. But either seems reasonable. |
I think deleting the entire comment is fine, for as long as it doesn't delete anything coming after another - return data # noqa: RET504 # fmt:skip
+ return data # fmt: skip |
I agree! |
I think this is all here if anyone is interested in a good issue: ruff/crates/ruff_linter/src/fix/edits.rs Line 65 in 940df67
|
Is there a standard or a strong feeling here on preserving trailing whitespace following 'Preserved' comments? Meaning: can: both resolve to: or is there a conceivable edge case where that matters? At any rate, I believe I've mostly got this but will spend some time tomorrow getting the testing framework and everything set up, should work regardless of the above, just changes the logic a bit to save those characters if we want 'em. |
It should be fine to remove trailing whitespace but just a note that any other comments shouldn't be deleted (#12251 (comment)). |
@jeremeybingham Can you open the PR? I can help you debug these test failures. |
will try asap, yes - have "fixed" my way into various fun new failure modes, and am now trying to consolidate the working bits of all that into something that compiles. |
## Summary Extends deletions for RUF100, deleting trailing text from noqa directives, while preserving upcoming comments on the same line if any. In cases where it deletes a comment up to another comment on the same line, the whitespace between them is now shown to be in the autofix in the diagnostic as well. Leading whitespace before the removed comment is not, though. Fixes #12251 ## Test Plan `cargo test`
I think it applies to all error codes, but let me give an example where I encountered that.
Consider:
Which is a violation of
RET504
- unnecessary assignment.I needed to perform the assignment and
return data
, notreturn do_some_transformations()
, so added anoqa: RET504
with explanation of why I want to bypass the rule:Then I disabled
RET504
inruff
config completely, and thisnoqa
became unused. Here is whereRUF100
comes into play, as it complains on unused error codes, and provides a fix.The fix was:
While I believe it should have been:
As it's probably quite safe to assume that entire content of the comment
noqa
is part of is explaining why a rule should by bypassed.RUF100
ruff check --fix
0.5.1
.The text was updated successfully, but these errors were encountered: