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

Clarification on DiagnosticTag #1696

Closed
lewis6991 opened this issue Mar 22, 2023 · 7 comments
Closed

Clarification on DiagnosticTag #1696

lewis6991 opened this issue Mar 22, 2023 · 7 comments

Comments

@lewis6991
Copy link

Would it be possible to get further clarification on how clients are supposed to handle DiagnosticTag?

export namespace DiagnosticTag {
	/**
	 * Unused or unnecessary code.
	 *
	 * Clients are allowed to render diagnostics with this tag faded out
	 * instead of having an error squiggle.
	 */
	export const Unnecessary: 1 = 1;
	/**
	 * Deprecated or obsolete code.
	 *
	 * Clients are allowed to rendered diagnostics with this tag strike through.
	 */
	export const Deprecated: 2 = 2;
}

According to the pyright maintainers (microsoft/pyright#1118 (comment)), diagnostics with the Unnecessary tag should not be treated as "real" diagnostics and should just be rendered faded and excluding from statuslines, sign column, inline text, etc. And, it should be considered a bug if any editor treats diagnostics with these tags as normal diagnostics. However, the spec does not say this explicitly.

Can further clarification be provided on how clients should exactly implement diagnostics with these tags?

@dbaeumer
Copy link
Member

Actually LSP always state away from defining UI for the client (and it will). Clients may offer filter mechanism or other means to make them not show in the UI.

Even VS Code doesn't hide them (at least in TypeScript)

image

I will close the issue since I really don't want to enforce UI rendering in the LSP specification.

@lewis6991
Copy link
Author

Many thanks!

@lewis6991
Copy link
Author

lewis6991 commented Mar 23, 2023

So Pylance doesn't report these as problems:

image

How can vscode be inconsistent here (note I don't use this editor)? Surely in both cases, the diagnostic is just a diagnostic with hint? Is this because vscode doesn't report hints as problems?

@rchl
Copy link
Contributor

rchl commented Mar 23, 2023

severity is optional so it might be that in case of Pylance it's not set and that's how VSCode handles it.

@lewis6991
Copy link
Author

lewis6991 commented Mar 23, 2023

Unfortunately not in this case. This is the diagnostic:

{
  "message": "\"_validator\" is not accessed",
  "range": {
    "end": {
      "character": 30,
      "line": 118
    },
    "start": {
      "character": 20,
      "line": 118
    }
  },
  "severity": 4,
  "source": "Pyright",
  "tags": [ 1 ]
}

@rchl
Copy link
Contributor

rchl commented Mar 23, 2023

So then VSCode doesn't treat "hint" diagnostics as problems. In case of TS it seems to be a "warning".

@dbaeumer
Copy link
Member

That is correct: hints are not shown in the problems list in VS Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants