Fix missing Pylance diagnostics in Visual Studio - #8575
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
🔒 Automated review in progress — @rchiodo is auto-reviewing this PR. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
| // and hence we don't know if this is workspace or a loose files case. | ||
| _server = new LanguageServer(Site, JoinableTaskContext, this.OnSendToServer); | ||
| InitializationOptions = null; | ||
|
|
There was a problem hiding this comment.
📍 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; | ||
|
|
There was a problem hiding this comment.
📍 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.
|
Looks good and directly addresses the missing-diagnostics symptom. Two small follow-ups worth considering: verify the serialized initialize request actually carries |
rchiodo
left a comment
There was a problem hiding this comment.
Approved via Review Center.
|
would be nice to have a test |



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/publishDiagnosticsand instead wait for theclient 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
disablePullDiagnosticstotrue.This keeps Pylance on the existing push-diagnostics path, which Visual Studio
already routes to editor squiggles and the Error List.
Validation
Built
PythonTools.csprojsuccessfully for Debug/VS 18.Fixes #8558