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

Double-check for interpreters when running diagnostics #12158

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/11870.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Double-check for interpreters when running diagnostics before displaying the "Python is not installed" message.
10 changes: 9 additions & 1 deletion src/client/application/diagnostics/checks/pythonInterpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,17 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService {
}

const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
const hasInterpreters = await interpreterService.hasInterpreters;
let hasInterpreters = await interpreterService.hasInterpreters;

if (!hasInterpreters) {
// hasInterpreters being false can mean one of 2 things:
// 1. getInterpreters hasn't returned any interpreters;
// 2. getInterpreters hasn't run yet.
// We want to make sure that false comes from 1, so we're adding this fix until we refactor interpreter discovery.
// Also see https://github.com/microsoft/vscode-python/issues/3023.
interpreterService.getInterpreters(resource).ignoreErrors();
kimadeline marked this conversation as resolved.
Show resolved Hide resolved
hasInterpreters = await interpreterService.hasInterpreters;

return [new InvalidPythonInterpreterDiagnostic(DiagnosticCodes.NoPythonInterpretersDiagnostic, resource)];
}

Expand Down