astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.

Home Page:https://docs.astral.sh/ruff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`ruff server`: Code action for re-enabling rules when cursor is on noqa comments

T-256 opened this issue · comments

commented

Could it possible instead of clearing noqa by hand, add code action when moving cursor on noqa code comments?
For example, moving cursor on # noqa:, show these code actions:

  • Ruff (ANN201): Re-enable for this line.
  • Ruff (D103): Re-enable for this line.
  • Re-enable all disabled rules for this line.

Originally posted by @T-256 in #11276 (comment)

commented

Closing as it's not possible with today LSP specification to determine the cursor position.

Would it be possible to implement this as a potential refactor? I'm not that familiar with the LSP spec but there must be a way to publish code actions based on the current position (e.g. refactors)

Actually, this is supported by the code action request. It sends an optional range field that can be used to provide additional code actions.

I think we could do this! (And it would be a nice feature to have)