Skip to content

Commit 34873ae

Browse files
committed
Fixed linting error (#DH-21980)
1 parent 4996095 commit 34873ae

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/controllers/PipServerController.spec.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
22
import * as vscode from 'vscode';
33
import { PipServerController } from './PipServerController';
4-
import type { PythonEnvironment } from '../util';
4+
import type { PythonEnvironment, PythonEnvironmentApi } from '../util';
55
import type { IServerManager, IToastService } from '../types';
66

77
// See __mocks__/vscode.ts for the mock implementation
@@ -20,7 +20,9 @@ vi.mock('../services', async () => {
2020
await vi.importActual<typeof import('../services')>('../services');
2121
return {
2222
...actual,
23-
pollUntilTrue: vi.fn().mockReturnValue({ promise: Promise.resolve(), cancel: vi.fn() }),
23+
pollUntilTrue: vi
24+
.fn()
25+
.mockReturnValue({ promise: Promise.resolve(), cancel: vi.fn() }),
2426
};
2527
});
2628

@@ -57,7 +59,7 @@ function createMockExtension(
5759
isActive: boolean,
5860
envResult: PythonEnvironment | undefined,
5961
packagesResult: typeof mockPackages | undefined
60-
) {
62+
): vscode.Extension<PythonEnvironmentApi> {
6163
const api = {
6264
getEnvironment: vi.fn().mockResolvedValue(envResult),
6365
getPackages: vi.fn().mockResolvedValue(packagesResult),
@@ -67,7 +69,7 @@ function createMockExtension(
6769
isActive,
6870
activate: vi.fn().mockResolvedValue(undefined),
6971
exports: api,
70-
};
72+
} as unknown as vscode.Extension<PythonEnvironmentApi>;
7173
}
7274

7375
function createController(): PipServerController {
@@ -182,7 +184,10 @@ describe('checkPipInstall', () => {
182184
it('returns isAvailable false on unsupported platform', async () => {
183185
vi.stubEnv('PLATFORM', 'win32');
184186
const originalPlatform = process.platform;
185-
Object.defineProperty(process, 'platform', { value: 'win32', configurable: true });
187+
Object.defineProperty(process, 'platform', {
188+
value: 'win32',
189+
configurable: true,
190+
});
186191

187192
const controller = createController();
188193
const result = await controller.checkPipInstall();
@@ -220,12 +225,18 @@ describe('checkPipInstall', () => {
220225
});
221226

222227
it('returns isAvailable false when getEnvironment returns null during package check', async () => {
223-
const mockExtWithEnv = createMockExtension(true, mockEnvironment, undefined);
228+
const mockExtWithEnv = createMockExtension(
229+
true,
230+
mockEnvironment,
231+
undefined
232+
);
224233
const mockExtNoEnv = createMockExtension(true, undefined, undefined);
225234

226235
vi.mocked(getPythonEnvsExtensionApi)
227236
.mockReturnValueOnce(
228-
mockExtWithEnv as unknown as ReturnType<typeof getPythonEnvsExtensionApi>
237+
mockExtWithEnv as unknown as ReturnType<
238+
typeof getPythonEnvsExtensionApi
239+
>
229240
)
230241
.mockReturnValueOnce(
231242
mockExtNoEnv as unknown as ReturnType<typeof getPythonEnvsExtensionApi>
@@ -246,7 +257,11 @@ describe('checkPipInstall', () => {
246257
version: '1.26.0',
247258
},
248259
];
249-
const mockExt = createMockExtension(true, mockEnvironment, packagesWithoutDh);
260+
const mockExt = createMockExtension(
261+
true,
262+
mockEnvironment,
263+
packagesWithoutDh
264+
);
250265
vi.mocked(getPythonEnvsExtensionApi).mockReturnValue(
251266
mockExt as unknown as ReturnType<typeof getPythonEnvsExtensionApi>
252267
);

src/util/extensionApiUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ interface DidChangePackagesEventArgs {
6767
export type GetEnvironmentScope = undefined | vscode.Uri;
6868

6969
/** Python Environments extension API (ms-python.vscode-python-envs) */
70-
interface PythonEnvironmentApi {
71-
getEnvironment(scope: GetEnvironmentScope): Promise<PythonEnvironment | undefined>;
70+
export interface PythonEnvironmentApi {
71+
getEnvironment(
72+
scope: GetEnvironmentScope
73+
): Promise<PythonEnvironment | undefined>;
7274
getPackages(environment: PythonEnvironment): Promise<Package[] | undefined>;
7375
onDidChangePackages: vscode.Event<DidChangePackagesEventArgs>;
7476
}

0 commit comments

Comments
 (0)