pyright icon indicating copy to clipboard operation
pyright copied to clipboard

pyright: ignore[reportUnused...] does not suppress "information"

Open figuld opened this issue 1 year ago • 3 comments

Describe the bug https://pyright-play.net/?reportUnusedImport=true&reportUnusedVariable=true&reportUnusedClass=true&reportUnusedFunction=true&reportUnusedCallResult=true&code=JYWwDg9gTgLgBBAzgGjognoucDEczpTADmAFjAFxwkB20ApgNpT2SwCqNArovQCYBJcNBgBdAFDi%2B9AGZwZXGgAoAhqgBGASgrjs2AMYAbFYiyce-KrnyES5KrQbNWI87z4BhY6Yl6-%2BE0RJP2k5RQs%2BJW1sPAIiMkpqYjoWZzYYN34AMUV9GGAIGl9-bDBA4L0wIhoYJQxEADp6AA96fS4YFXVDek1dPX04AF44AEYYm3j7JJSmFnTMvgA1FSIunuLsFhguKBo4dUkFZVHUACZNCbi7RMdU%2Bddudw8VQ0MAJXpELkMxIA When using # pyright: ignore or # pyright: ignore[reportUnused...] it suppresses the errors, but not the hints (grey highlight), with the exception of reportUnusedCallResult.

Code or Screenshots Image

VS Code extension or command-line Shouldn't matter, because I used the playground to show the bug. I use Neovim and these hints are too annoying to ignore, but I don't want to disable these rules for the whole project.

figuld avatar Mar 20 '25 13:03 figuld

Yes, this is as designed. These are not regular diagnostics (errors, warnings, or informations). These are hints with tags that tell an editor to display the text in a grayed-out manner. There is no way to suppress these because they are not regular diagnostics, and they should not be presented as such.

Some editors display tagged hints in a manner that can be annoying. If you don't want pyright to generate tagged hints, you can set "pyright.disableTaggedHints" to true.

See this issue for more background on this topic.

erictraut avatar Mar 20 '25 15:03 erictraut

Some editors display tagged hints in a manner that can be annoying. If you don't want pyright to generate tagged hints, you can set "pyright.disableTaggedHints" to true.

But what if I want to see these hints in general, but disable them only on certain lines. Btw, how are the tagged hints different from the diagnostic rules set to "information"?

I think, it would be much better to create new Diagnostic rules based on the tagged hints (e.g. basedpyright's reportUnusedParameter, reportUnreachable, etc.) and set them to "information" by default. (And then remove the tagged hints, because they would not be needed anymore.) This way they can be conveniently set to higher severity values or suppressed by the ignore comment. Is it a good feature request?

figuld avatar Mar 20 '25 19:03 figuld

This has been discussed and debated at some length already. We have no plans to change the current behavior.

erictraut avatar Mar 20 '25 19:03 erictraut