Skip to content

Commit 9929f76

Browse files
author
Kartik Raj
authored
Ensure prompts related to environment selection do not show up at startup (#19483)
1 parent 4ecf02b commit 9929f76

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/client/application/diagnostics/checks/pythonInterpreter.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
100100
);
101101
}
102102

103-
public async diagnose(resource: Resource): Promise<IDiagnostic[]> {
103+
// eslint-disable-next-line class-methods-use-this
104+
public async diagnose(_resource: Resource): Promise<IDiagnostic[]> {
105+
return [];
106+
}
107+
108+
public async _manualDiagnose(resource: Resource): Promise<IDiagnostic[]> {
104109
const workspaceService = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService);
105110
const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
106111
const hasInterpreters = await interpreterService.hasInterpreters();
@@ -130,7 +135,7 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
130135
}
131136

132137
public async triggerEnvSelectionIfNecessary(resource: Resource): Promise<boolean> {
133-
const diagnostics = await this.diagnose(resource);
138+
const diagnostics = await this._manualDiagnose(resource);
134139
if (!diagnostics.length) {
135140
return true;
136141
}

src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { expect } from 'chai';
77
import * as typemoq from 'typemoq';
88
import { EventEmitter, Uri } from 'vscode';
9-
import { IExtensionSingleActivationService } from '../../../../client/activation/types';
109
import { BaseDiagnosticsService } from '../../../../client/application/diagnostics/base';
1110
import { InvalidLaunchJsonDebuggerDiagnostic } from '../../../../client/application/diagnostics/checks/invalidLaunchJsonDebugger';
1211
import {
@@ -24,7 +23,6 @@ import {
2423
IDiagnostic,
2524
IDiagnosticCommand,
2625
IDiagnosticHandlerService,
27-
IDiagnosticsService,
2826
} from '../../../../client/application/diagnostics/types';
2927
import { CommandsWithoutArgs } from '../../../../client/common/application/commands';
3028
import { ICommandManager, IWorkspaceService } from '../../../../client/common/application/types';
@@ -39,7 +37,7 @@ import { EnvironmentType, PythonEnvironment } from '../../../../client/pythonEnv
3937
import { sleep } from '../../../core';
4038

4139
suite('Application Diagnostics - Checks Python Interpreter', () => {
42-
let diagnosticService: IDiagnosticsService & IExtensionSingleActivationService;
40+
let diagnosticService: InvalidPythonInterpreterService;
4341
let messageHandler: typemoq.IMock<IDiagnosticHandlerService<MessageCommandPrompt>>;
4442
let commandFactory: typemoq.IMock<IDiagnosticsCommandFactory>;
4543
let interpreterService: typemoq.IMock<IInterpreterService>;
@@ -157,6 +155,11 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
157155
}
158156
});
159157

158+
test('Should return empty diagnostics', async () => {
159+
const diagnostics = await diagnosticService.diagnose(undefined);
160+
expect(diagnostics).to.be.deep.equal([], 'not the same');
161+
});
162+
160163
test('Should return diagnostics if there are no interpreters after double-checking', async () => {
161164
interpreterService
162165
.setup((i) => i.hasInterpreters())
@@ -167,7 +170,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
167170
.returns(() => [])
168171
.verifiable(typemoq.Times.once());
169172

170-
const diagnostics = await diagnosticService.diagnose(undefined);
173+
const diagnostics = await diagnosticService._manualDiagnose(undefined);
171174
expect(diagnostics).to.be.deep.equal(
172175
[
173176
new InvalidPythonInterpreterDiagnostic(
@@ -192,7 +195,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
192195
})
193196
.verifiable(typemoq.Times.once());
194197

195-
const diagnostics = await diagnosticService.diagnose(undefined);
198+
const diagnostics = await diagnosticService._manualDiagnose(undefined);
196199
expect(diagnostics).to.be.deep.equal(
197200
[
198201
new InvalidPythonInterpreterDiagnostic(
@@ -217,7 +220,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
217220
})
218221
.verifiable(typemoq.Times.once());
219222

220-
const diagnostics = await diagnosticService.diagnose(undefined);
223+
const diagnostics = await diagnosticService._manualDiagnose(undefined);
221224
expect(diagnostics).to.be.deep.equal([], 'not the same');
222225
interpreterService.verifyAll();
223226
});

0 commit comments

Comments
 (0)