basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

Make `pyright: ignore[...]` disable tagged hints

Open REmerald opened this issue 11 months ago • 5 comments

Description

https://basedpyright.com/?typeCheckingMode=standard&code=JYWwDg9gTgLgBBAzgGjognoucDEczpTADmAFjAFxwkB20ApgNpT2SwCqNArovQCYBJcNBgBdAFDi%2B9AGZwZXGgAoAhqgBGASiq58hEuSq0GzViM49%2BABRVQVIejHpQJ2bAGMANisRYLvPh08AiIySmpiOhZTNhh-fgBhb19XNzSwH0RJNOk5RUs%2BJW1sYP0wo0iTFlj4vgAxRXcYYAgaVLTsDN9stzAiGhglDEQAOnoAD3p3LhgVdU96TXE09zgAXjgARhK9UMMIqKZq824AgDVbYDmF9rgWGC4oGjh1Zbd7x%2BfdEINw42jjhwaCwVO5SNd6KIgA

Currently, if I put # pyright: ignore[...] with reportUnreachable, reportUnused* (except reportUnusedCallResult) on the respective lines, the gray highlight doesn't disappear, unless I set these options to true in the config, (this is different from pyright, where setting the options to true doesn't help).

I want to see the tagged hints in general, but disable them only on certain lines with the ignore comment.

I raised the issue about this in the pyright repo, but they didn't want to change it.

Btw, how are the tagged hints different from the diagnostic rules set to "information"? Maybe it would make sense to just remove basedpyright.disableTaggedHints and replace it with the new diagnostic rules set to "information" by default? (If tagged hints still have some "rules" left, that don't have an equivalent like reportUnreachabe, reportUnusedParameter, etc.)

REmerald avatar Mar 20 '25 20:03 REmerald

Currently, if I put # pyright: ignore[...] with reportUnreachable, reportUnused* (except reportUnusedCallResult) on the respective lines, the gray highlight doesn't disappear, unless I set these options to true in the config

yeah this inconsistent behaviour is quite confusing and partially unintentional, we should probably make it work consistently regardless of what diagnostic level the rule is set to.

the original reasoning behind this behavior is that tagged hints aren't errors and are displayed in a very subtle way so there's no reason to disable them.

(this is different from pyright, where setting the options to true doesn't help).

in pyright they aren't associated with a diagnostic rule at all which is why they are impossible to disable with an ignore comment even when the rule is disabled.

Btw, how are the tagged hints different from the diagnostic rules set to "information"?

as eric said some editors display tags in an annoying way that makes them look similar to information, but in vscode they look completely different:

image

and hints without a tag look like this:

image

information diagnostics also show up in the vscode "problems" tab and the CLI while hints do not.

more info here

personally i don't see the point of "information" level diagnostics, especially since hints are their own diagnostic level in basedpyright. information diagnostics are displayed more like warnings and errors but aren't supposed to be treated as such. reveal_type is the only use case i can think of, but i've been considering updating it to report as a warning or error instead (#315)

Maybe it would make sense to just remove basedpyright.disableTaggedHints and replace it with the new diagnostic rules set to "information" by default? (If tagged hints still have some "rules" left, that don't have an equivalent like reportUnreachabe, reportUnusedParameter, etc.)

yeah i guess that setting is redundant in basedpyright. there are no diagnostics left to my knowledge that can only be reported as a hint. if there are any, they should be converted to a regular diagnostic so the user can configure it to whatever diagnostic level they want

DetachHead avatar Mar 20 '25 21:03 DetachHead

@DetachHead, I didn't notice the "hint" diagnostic level (that you could set every diagnostic to) before and thought hints diagnostics were separate from the logic and/or code of the error/warning/information diagnostics. (Maybe I slightly misunderstood your answer.)

imho, this makes ignore not being able to disable some hints look more like an actual bug rather than just "inconsistent behavior".
Sure, hints are more subtle than the other diagnostic level, but you still notice some code being highlighted differently than the other.

(I looked at the issue again, because I had a false positive with reportUnreachable and had to disable the diagnostic in a special file-level comment.)

REmerald avatar May 03 '25 01:05 REmerald

yeah i agree, i've also since learnt that other editors such as pycharm display hints in a much less subtle way, such that they look more like a warning

DetachHead avatar May 11 '25 08:05 DetachHead

Just came here to comment, that Helix also has the annoying "HINT in subtle blue color, "foo" is not accessed and adding # pyright: ignore[reportUnusedParameter] doesn't remove that. It's especially annoying since a lot of FastAPI injected dependencies are reported as such. So do I just disable that altogether in helix config? Or there is no way to make it go away on line-by-line basis?

soderluk avatar Oct 30 '25 09:10 soderluk

maybe we should just repurpose basedpyright.disableTaggedHints to disable all hints for editors where hints are too obnoxious. currently i don't think the setting does anything anymore

DetachHead avatar Nov 01 '25 10:11 DetachHead