Skip to content

Fix missing Pylance diagnostics in Visual Studio - #8575

Merged
StellaHuang95 merged 1 commit into
mainfrom
fixErrorList
Jul 13, 2026
Merged

Fix missing Pylance diagnostics in Visual Studio#8575
StellaHuang95 merged 1 commit into
mainfrom
fixErrorList

Conversation

@StellaHuang95

Copy link
Copy Markdown
Contributor

Context

Pylance enables LSP pull diagnostics when the client advertises
textDocument.diagnostic.dynamicRegistration.

Visual Studio advertises this capability, causing Pylance to stop publishing
diagnostics through textDocument/publishDiagnostics and instead wait for the
client to pull them. PTVS does not currently surface these pulled diagnostics,
so errors such as unresolved imports produce neither editor squiggles nor Error
List entries.

Fix

Set the Pylance initialization option disablePullDiagnostics to true.

This keeps Pylance on the existing push-diagnostics path, which Visual Studio
already routes to editor squiggles and the Error List.

Validation

Built PythonTools.csproj successfully for Debug/VS 18.

Fixes #8558

@StellaHuang95
StellaHuang95 requested a review from a team as a code owner July 13, 2026 20:22
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@rchiodo

rchiodo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

🔒 Automated review in progress — @rchiodo is auto-reviewing this PR.

@StellaHuang95

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@sonarqubecloud

Copy link
Copy Markdown

// and hence we don't know if this is workspace or a loose files case.
_server = new LanguageServer(Site, JoinableTaskContext, this.OnSendToServer);
InitializationOptions = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📍 Python/Product/PythonTools/PythonTools/LanguageServerClient/PythonLanguageClient.cs:218
The Pylance server matches this key case-sensitively (initializationOptions?.disablePullDiagnostics in languageServerBase.ts:634). If PTVS's LSP client serializer applies a JSON naming policy (PascalCase/camelCase contract resolver), the wire key could diverge from disablePullDiagnostics and the option would be silently ignored, making this fix a no-op. Confirm by capturing the actual initialize request JSON (LSP trace) and asserting it contains "disablePullDiagnostics": true.

// and hence we don't know if this is workspace or a loose files case.
_server = new LanguageServer(Site, JoinableTaskContext, this.OnSendToServer);
InitializationOptions = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📍 Python/Product/PythonTools/PythonTools/LanguageServerClient/PythonLanguageClient.cs:218
Add a brief rationale comment so a future reader knows this is a deliberate workaround rather than an arbitrary toggle, e.g. // VS does not surface pulled diagnostics; keep Pylance on push diagnostics (Error List + squiggles). See #8558. This guards against an accidental future removal.

@rchiodo

rchiodo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Looks good and directly addresses the missing-diagnostics symptom. Two small follow-ups worth considering: verify the serialized initialize request actually carries disablePullDiagnostics, and add a short rationale comment on the toggle.

@rchiodo rchiodo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@heejaechang heejaechang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@bschnurr

Copy link
Copy Markdown
Member

would be nice to have a test

@StellaHuang95
StellaHuang95 enabled auto-merge (squash) July 13, 2026 21:01
@StellaHuang95
StellaHuang95 merged commit a730f24 into main Jul 13, 2026
11 checks passed
@StellaHuang95
StellaHuang95 deleted the fixErrorList branch July 13, 2026 21:22
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

Successfully merging this pull request may close these issues.

There is no warning on error list when imported module cannot be found.

4 participants