vscode-ruff icon indicating copy to clipboard operation
vscode-ruff copied to clipboard

Show rule explanation popup on hover in `pyproject.toml`

Open MicaelJarniac opened this issue 2 years ago • 6 comments

I noticed that when I hover my cursor over a # noqa: ABC123 comment in a .py file, it shows a popup explaining what the ABC123 rule is.

My suggestion is to have this popup also on the pyproject.toml file, when you hover over rules in the tool.ruff.[select|ignore|unfixable] sections, for example.

MicaelJarniac avatar Jun 20 '23 13:06 MicaelJarniac

Just for reference, this can be done on PyCharm with a plugin:

InSyncWithFoo avatar Oct 07 '24 17:10 InSyncWithFoo

.. Are there any updates on this? This would be really nice to have.

Soheab avatar Dec 05 '24 14:12 Soheab

.. Are there any updates on this? This would be really nice to have.

I think this could be better handled in a TOML specific extension like https://github.com/tamasfe/taplo/tree/master/editors/vscode at least in VS Code. The relevant issue seems to be https://github.com/tamasfe/taplo/issues/373 although I'm not sure why it's closed.

dhruvmanila avatar Dec 13 '24 10:12 dhruvmanila

I think we could do this by changing how we generate the schema: We can generate a schema for every enum value and use anyOf. This should allow us to set a description.

MichaReiser avatar Mar 18 '25 12:03 MichaReiser

SchemaStore recommends this approach:

{
  "oneOf": [
    { "const": "A001", "description": "# builtin-variable-shadowing (A001)\n\nDerived from..." },
    { "const": "A002", "description": "# builtin-argument-shadowing (A002)\n\nDerived from..." },
    ...
  ]
}

A small thing to note is that the descriptions cost a total of ~900KB in size. That's about 6 times the current schema's size when pretty printed using 2-space indentation and 8 or 9 times minified.

InSyncWithFoo avatar Mar 19 '25 01:03 InSyncWithFoo

I've been using https://github.com/Jannchie/ruff-ignore-explainer, which works great, but it would be lovely to have it folded into the main Ruff extension

IlanCosman avatar May 27 '25 03:05 IlanCosman