Skip to content
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

Provide code action to ignore the diagnostic (via noqa) #10594

Closed
dhruvmanila opened this issue Mar 26, 2024 · 0 comments · Fixed by #11276
Closed

Provide code action to ignore the diagnostic (via noqa) #10594

dhruvmanila opened this issue Mar 26, 2024 · 0 comments · Fixed by #11276
Assignees
Labels
server Related to the LSP server

Comments

@dhruvmanila
Copy link
Member

Provide "Disable for this line" code action to automatically add noqa comment for the selected diagnostic:

Screenshot 2024-03-26 at 09 00 23

Reference implementation in ruff-lsp: https://github.com/astral-sh/ruff-lsp/blob/187d7790be0783b9ac41ce025a724cf389bf575c/ruff_lsp/server.py#L1007-L1069

@dhruvmanila dhruvmanila added the server Related to the LSP server label Mar 26, 2024
@snowsignal snowsignal self-assigned this Mar 26, 2024
@snowsignal snowsignal added this to the Ruff Server: Beta milestone Apr 10, 2024
snowsignal added a commit that referenced this issue May 12, 2024
## Summary

Fixes #10594.

Code actions to disable a diagnostic via `noqa` comment are now
available.


https://github.com/astral-sh/ruff/assets/19577865/6d3bcf11-a9d9-499b-8c7f-a10cd39cfbba

`DiagnosticFix` has been changed so that `noqa` code actions appear even
for diagnostics with no available quick fix. It can contain quick fix
edits, `noqa` comment edits, or both.

## Test Plan

The scenarios that need to be tested are as follows:
* A code action to disable a diagnostic should be available for every
diagnostic.
* Using this code action should append to the appropriate line with the
diagnostic, or modify an existing `noqa` comment.
* Adding a `noqa` comment manually should make a diagnostic disappear
* `Fix all auto-fixable problems` should not add `noqa` comments
* Removing a code from a `noqa` comment should make the diagnostic
re-appear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Related to the LSP server
Projects
None yet
2 participants