From 360d03b33c220225e5a80d46fcb91262e97d6635 Mon Sep 17 00:00:00 2001 From: Positron Bot Date: Wed, 22 May 2024 18:25:46 +0000 Subject: [PATCH] Automated formatting fixes --- .../client/activation/node/analysisOptions.ts | 4 +- .../activation/node/languageClientFactory.ts | 10 +- extensions/positron-python/src/client/api.ts | 4 +- .../checks/invalidPythonPathInDebugger.ts | 6 +- .../diagnostics/checks/pythonInterpreter.ts | 6 +- .../diagnostics/commands/launchBrowser.ts | 6 +- .../common/application/commandManager.ts | 4 +- .../commands/reportIssueCommand.ts | 2 +- .../src/client/common/contextKey.ts | 5 +- .../client/common/installer/channelManager.ts | 2 +- .../client/common/process/currentProcess.ts | 2 +- .../common/process/pythonExecutionFactory.ts | 5 +- .../src/client/common/utils/async.ts | 4 +- .../src/client/common/utils/enum.ts | 2 +- .../src/client/common/utils/platform.ts | 2 +- .../src/client/common/utils/version.ts | 10 +- .../common/variables/systemVariables.ts | 12 +- .../debugger/extension/adapter/logging.ts | 5 +- .../extension/configuration/resolvers/base.ts | 3 +- .../src/client/deprecatedProposedApiTypes.ts | 4 +- .../positron-python/src/client/extension.ts | 4 +- .../src/client/extensionActivation.ts | 15 +- .../client/interpreter/autoSelection/index.ts | 11 +- .../interpreterSelector/commands/base.ts | 4 +- .../services/workspaceFolderUpdaterService.ts | 5 +- .../services/workspaceUpdaterService.ts | 5 +- .../client/interpreter/interpreterService.ts | 5 +- .../src/client/logging/index.ts | 4 +- .../src/client/positron/discoverer.ts | 6 +- .../src/client/positron/errorHandler.ts | 5 +- .../src/client/positron/manager.ts | 5 +- .../src/client/positron/session.ts | 5 +- .../base/info/pythonVersion.ts | 4 +- .../locators/composite/envsCollectionCache.ts | 6 +- .../composite/envsCollectionService.ts | 5 +- .../base/locators/wrappers.ts | 5 +- .../environmentManagers/condaService.ts | 5 +- .../common/environmentManagers/hatch.ts | 5 +- .../common/environmentManagers/poetry.ts | 5 +- .../creation/createEnvApi.ts | 11 +- .../src/client/pythonEnvironments/index.ts | 2 +- .../src/client/telemetry/importTracker.ts | 3 +- .../src/client/tensorBoard/helpers.ts | 6 +- .../src/client/testing/common/runner.ts | 5 +- .../testController/common/resultResolver.ts | 6 +- .../activation/activationManager.unit.test.ts | 14 +- .../jedi/jediAnalysisOptions.unit.test.ts | 5 +- .../activation/partialModeStatus.unit.test.ts | 20 +- .../jediPython27NotSupported.unit.test.ts | 70 +-- .../checks/macPythonInterpreter.unit.test.ts | 4 +- .../checks/pythonInterpreter.unit.test.ts | 24 +- extensions/positron-python/src/test/common.ts | 12 +- .../createNewFileCommand.unit.test.ts | 2 +- .../commands/reportIssueCommand.unit.test.ts | 4 +- .../src/test/common/configSettings.test.ts | 2 +- .../common/experiments/service.unit.test.ts | 12 +- .../installer/pipEnvInstaller.unit.test.ts | 6 +- .../installer/pipInstaller.unit.test.ts | 4 +- .../interpreterPathService.unit.test.ts | 12 +- .../common/platform/filesystem.unit.test.ts | 34 +- .../test/common/process/logger.unit.test.ts | 2 +- .../pythonExecutionFactory.unit.test.ts | 8 +- .../src/test/common/socketStream.test.ts | 24 +- .../terminals/activation.bash.unit.test.ts | 2 +- .../activation.commandPrompt.unit.test.ts | 6 +- .../terminals/activation.nushell.unit.test.ts | 2 +- .../common/terminals/activation.unit.test.ts | 12 +- .../terminals/activator/base.unit.test.ts | 4 +- .../terminals/activator/index.unit.test.ts | 4 +- .../test/common/terminals/helper.unit.test.ts | 2 +- .../shellDetectors.unit.test.ts | 4 +- .../test/common/utils/version.unit.test.ts | 80 ++-- .../variables/envVarsService.unit.test.ts | 17 +- .../environmentTypeComparer.unit.test.ts | 21 +- .../commands/resetInterpreter.unit.test.ts | 2 +- .../commands/setInterpreter.unit.test.ts | 44 +- .../interpreterSelector.unit.test.ts | 4 +- .../src/test/debugger/envVars.test.ts | 16 +- .../extension/adapter/factory.unit.test.ts | 4 +- .../outdatedDebuggerPrompt.unit.test.ts | 4 +- .../attachQuickPick/provider.unit.test.ts | 6 +- .../wmicProcessParser.unit.test.ts | 9 +- .../debugConfigurationService.unit.test.ts | 10 +- .../configuration/resolvers/base.unit.test.ts | 2 +- .../resolvers/launch.unit.test.ts | 5 +- .../extension/debugCommands.unit.test.ts | 2 +- .../src/test/debugger/utils.ts | 10 +- .../src/test/environmentApi.unit.test.ts | 8 +- .../src/test/extensionSettings.ts | 3 +- .../positron-python/src/test/initialize.ts | 2 +- .../install/channelManager.channels.test.ts | 8 +- .../install/channelManager.messages.test.ts | 8 +- .../activation/indicatorPrompt.unit.test.ts | 40 +- ...rminalEnvVarCollectionService.unit.test.ts | 56 +-- .../test/interpreters/display.unit.test.ts | 4 +- .../interpreterService.unit.test.ts | 6 +- .../activatedEnvLaunch.unit.test.ts | 50 +- .../virtualEnvs/virtualEnvPrompt.unit.test.ts | 6 +- .../jediLSExtensionManager.unit.test.ts | 8 +- .../pylanceLSExtensionManager.unit.test.ts | 20 +- .../test/languageServer/watcher.unit.test.ts | 440 +++++++++--------- .../src/test/mocks/autoSelector.ts | 3 +- .../src/test/mocks/mockDocument.ts | 6 +- .../src/test/mocks/mockTextEditor.ts | 10 +- .../src/test/mocks/moduleInstaller.ts | 5 +- .../src/test/mocks/vsc/arrays.ts | 2 +- .../src/test/mocks/vsc/extHostedTypes.ts | 14 +- .../src/test/mocks/vsc/index.ts | 12 +- extensions/positron-python/src/test/proc.ts | 2 +- .../codeActionProvider/main.unit.test.ts | 2 +- .../src/test/providers/repl.unit.test.ts | 2 +- .../environmentInfoService.functional.test.ts | 3 +- .../base/locatorUtils.unit.test.ts | 18 +- .../composite/envsResolver.unit.test.ts | 9 +- .../locators/lowLevel/watcherTestUtils.ts | 5 +- .../environmentManagers/conda.unit.test.ts | 32 +- .../common/installCheckUtils.unit.test.ts | 2 +- .../globalPipInTerminalTrigger.unit.test.ts | 14 +- .../src/test/startupTelemetry.unit.test.ts | 4 +- .../tensorBoard/tensorBoardSession.test.ts | 4 +- .../test/terminals/activation.unit.test.ts | 12 +- .../codeExecutionManager.unit.test.ts | 2 +- .../djangoShellCodeExect.unit.test.ts | 4 +- .../terminals/codeExecution/helper.test.ts | 2 +- .../terminalCodeExec.unit.test.ts | 32 +- .../terminals/serviceRegistry.unit.test.ts | 2 +- .../positron-python/src/test/testBootstrap.ts | 17 +- .../testing/common/debugLauncher.unit.test.ts | 2 +- .../testing/common/testingAdapter.test.ts | 62 ++- .../test/testing/configuration.unit.test.ts | 2 +- .../pytestDiscoveryAdapter.unit.test.ts | 26 +- .../pytestExecutionAdapter.unit.test.ts | 22 +- .../resultResolver.unit.test.ts | 22 +- .../testCancellationRunAdapters.unit.test.ts | 14 +- .../testDiscoveryAdapter.unit.test.ts | 12 +- .../testExecutionAdapter.unit.test.ts | 22 +- .../workspaceTestAdapter.unit.test.ts | 44 +- 137 files changed, 919 insertions(+), 959 deletions(-) diff --git a/extensions/positron-python/src/client/activation/node/analysisOptions.ts b/extensions/positron-python/src/client/activation/node/analysisOptions.ts index 1722da027a7..71295649c25 100644 --- a/extensions/positron-python/src/client/activation/node/analysisOptions.ts +++ b/extensions/positron-python/src/client/activation/node/analysisOptions.ts @@ -19,9 +19,9 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt // eslint-disable-next-line class-methods-use-this protected async getInitializationOptions(): Promise { - return { + return ({ experimentationSupport: true, trustedWorkspaceSupport: true, - } as unknown as LanguageClientOptions; + } as unknown) as LanguageClientOptions; } } diff --git a/extensions/positron-python/src/client/activation/node/languageClientFactory.ts b/extensions/positron-python/src/client/activation/node/languageClientFactory.ts index fdd410e2132..9543f265468 100644 --- a/extensions/positron-python/src/client/activation/node/languageClientFactory.ts +++ b/extensions/positron-python/src/client/activation/node/languageClientFactory.ts @@ -14,10 +14,7 @@ import { ILanguageClientFactory } from '../types'; export const PYLANCE_NAME = 'Pylance'; export class NodeLanguageClientFactory implements ILanguageClientFactory { - constructor( - private readonly fs: IFileSystem, - private readonly extensions: IExtensions, - ) {} + constructor(private readonly fs: IFileSystem, private readonly extensions: IExtensions) {} public async createLanguageClient( _resource: Resource, @@ -25,9 +22,8 @@ export class NodeLanguageClientFactory implements ILanguageClientFactory { clientOptions: LanguageClientOptions, ): Promise { // this must exist for node language client - const commandArgs = ( - clientOptions.connectionOptions?.cancellationStrategy as FileBasedCancellationStrategy - ).getCommandLineArguments(); + const commandArgs = (clientOptions.connectionOptions + ?.cancellationStrategy as FileBasedCancellationStrategy).getCommandLineArguments(); const extension = this.extensions.getExtension(PYLANCE_EXTENSION_ID); const languageServerFolder = extension ? extension.extensionPath : ''; diff --git a/extensions/positron-python/src/client/api.ts b/extensions/positron-python/src/client/api.ts index 5ffe7327b13..aaaba540af2 100644 --- a/extensions/positron-python/src/client/api.ts +++ b/extensions/positron-python/src/client/api.ts @@ -82,7 +82,9 @@ export function buildApi( * * If no folder is present, it returns the global setting. * @returns {({ execCommand: string[] | undefined })} */ - getExecutionDetails(resource?: Resource): { + getExecutionDetails( + resource?: Resource, + ): { /** * E.g of execution commands returned could be, * * `['']` diff --git a/extensions/positron-python/src/client/application/diagnostics/checks/invalidPythonPathInDebugger.ts b/extensions/positron-python/src/client/application/diagnostics/checks/invalidPythonPathInDebugger.ts index 0f2b0fbb467..f08c0995683 100644 --- a/extensions/positron-python/src/client/application/diagnostics/checks/invalidPythonPathInDebugger.ts +++ b/extensions/positron-python/src/client/application/diagnostics/checks/invalidPythonPathInDebugger.ts @@ -53,10 +53,8 @@ class InvalidPythonPathInDebuggerDiagnostic extends BaseDiagnostic { export const InvalidPythonPathInDebuggerServiceId = 'InvalidPythonPathInDebuggerServiceId'; @injectable() -export class InvalidPythonPathInDebuggerService - extends BaseDiagnosticsService - implements IInvalidPythonPathInDebuggerService -{ +export class InvalidPythonPathInDebuggerService extends BaseDiagnosticsService + implements IInvalidPythonPathInDebuggerService { constructor( @inject(IServiceContainer) serviceContainer: IServiceContainer, @inject(IWorkspaceService) private readonly workspace: IWorkspaceService, diff --git a/extensions/positron-python/src/client/application/diagnostics/checks/pythonInterpreter.ts b/extensions/positron-python/src/client/application/diagnostics/checks/pythonInterpreter.ts index b29e3228608..58a2cfbfb73 100644 --- a/extensions/positron-python/src/client/application/diagnostics/checks/pythonInterpreter.ts +++ b/extensions/positron-python/src/client/application/diagnostics/checks/pythonInterpreter.ts @@ -103,10 +103,8 @@ export class DefaultShellDiagnostic extends BaseDiagnostic { export const InvalidPythonInterpreterServiceId = 'InvalidPythonInterpreterServiceId'; @injectable() -export class InvalidPythonInterpreterService - extends BaseDiagnosticsService - implements IExtensionSingleActivationService -{ +export class InvalidPythonInterpreterService extends BaseDiagnosticsService + implements IExtensionSingleActivationService { public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: true }; constructor( diff --git a/extensions/positron-python/src/client/application/diagnostics/commands/launchBrowser.ts b/extensions/positron-python/src/client/application/diagnostics/commands/launchBrowser.ts index 326d1125b72..4509044f677 100644 --- a/extensions/positron-python/src/client/application/diagnostics/commands/launchBrowser.ts +++ b/extensions/positron-python/src/client/application/diagnostics/commands/launchBrowser.ts @@ -11,11 +11,7 @@ import { IDiagnostic } from '../types'; import { BaseDiagnosticCommand } from './base'; export class LaunchBrowserCommand extends BaseDiagnosticCommand { - constructor( - diagnostic: IDiagnostic, - private serviceContainer: IServiceContainer, - private url: string, - ) { + constructor(diagnostic: IDiagnostic, private serviceContainer: IServiceContainer, private url: string) { super(diagnostic); } public async invoke(): Promise { diff --git a/extensions/positron-python/src/client/common/application/commandManager.ts b/extensions/positron-python/src/client/common/application/commandManager.ts index 9e377dc0629..9e1f34a5885 100644 --- a/extensions/positron-python/src/client/common/application/commandManager.ts +++ b/extensions/positron-python/src/client/common/application/commandManager.ts @@ -23,7 +23,7 @@ export class CommandManager implements ICommandManager { // eslint-disable-next-line class-methods-use-this public registerCommand< E extends keyof ICommandNameArgumentTypeMapping, - U extends ICommandNameArgumentTypeMapping[E], + U extends ICommandNameArgumentTypeMapping[E] // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any >(command: E, callback: (...args: U) => any, thisArg?: any): Disposable { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -73,7 +73,7 @@ export class CommandManager implements ICommandManager { public executeCommand< T, E extends keyof ICommandNameArgumentTypeMapping, - U extends ICommandNameArgumentTypeMapping[E], + U extends ICommandNameArgumentTypeMapping[E] >(command: E, ...rest: U): Thenable { return commands.executeCommand(command, ...rest); } diff --git a/extensions/positron-python/src/client/common/application/commands/reportIssueCommand.ts b/extensions/positron-python/src/client/common/application/commands/reportIssueCommand.ts index eac804db148..f5f1f0ac0c0 100644 --- a/extensions/positron-python/src/client/common/application/commands/reportIssueCommand.ts +++ b/extensions/positron-python/src/client/common/application/commands/reportIssueCommand.ts @@ -61,7 +61,7 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ if (argSetting) { if (typeof argSetting === 'object') { let propertyHeaderAdded = false; - const argSettingsDict = settings[property] as unknown as Record; + const argSettingsDict = (settings[property] as unknown) as Record; if (typeof argSettingsDict === 'object') { Object.keys(argSetting).forEach((item) => { const prop = argSetting[item]; diff --git a/extensions/positron-python/src/client/common/contextKey.ts b/extensions/positron-python/src/client/common/contextKey.ts index b37e163919b..96022a3ba3c 100644 --- a/extensions/positron-python/src/client/common/contextKey.ts +++ b/extensions/positron-python/src/client/common/contextKey.ts @@ -6,10 +6,7 @@ export class ContextKey { } private lastValue?: boolean; - constructor( - private name: string, - private commandManager: ICommandManager, - ) {} + constructor(private name: string, private commandManager: ICommandManager) {} public async set(value: boolean): Promise { if (this.lastValue === value) { diff --git a/extensions/positron-python/src/client/common/installer/channelManager.ts b/extensions/positron-python/src/client/common/installer/channelManager.ts index 7aec230620f..d2950859ab8 100644 --- a/extensions/positron-python/src/client/common/installer/channelManager.ts +++ b/extensions/positron-python/src/client/common/installer/channelManager.ts @@ -42,7 +42,7 @@ export class InstallationChannelManager implements IInstallationChannelManager { installer, }; }); - const selection = await appShell.showQuickPick<(typeof options)[0]>(options, { + const selection = await appShell.showQuickPick(options, { matchOnDescription: true, matchOnDetail: true, placeHolder, diff --git a/extensions/positron-python/src/client/common/process/currentProcess.ts b/extensions/positron-python/src/client/common/process/currentProcess.ts index 4d549630279..b80c32e97b7 100644 --- a/extensions/positron-python/src/client/common/process/currentProcess.ts +++ b/extensions/positron-python/src/client/common/process/currentProcess.ts @@ -13,7 +13,7 @@ export class CurrentProcess implements ICurrentProcess { return process as any; }; public get env(): EnvironmentVariables { - return process.env as any as EnvironmentVariables; + return (process.env as any) as EnvironmentVariables; } public get argv(): string[] { return process.argv; diff --git a/extensions/positron-python/src/client/common/process/pythonExecutionFactory.ts b/extensions/positron-python/src/client/common/process/pythonExecutionFactory.ts index b7234b9fbbd..fc13e7f2346 100644 --- a/extensions/positron-python/src/client/common/process/pythonExecutionFactory.ts +++ b/extensions/positron-python/src/client/common/process/pythonExecutionFactory.ts @@ -52,8 +52,9 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { public async create(options: ExecutionFactoryCreationOptions): Promise { let { pythonPath } = options; if (!pythonPath || pythonPath === 'python') { - const activatedEnvLaunch = - this.serviceContainer.get(IActivatedEnvironmentLaunch); + const activatedEnvLaunch = this.serviceContainer.get( + IActivatedEnvironmentLaunch, + ); await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv(); // If python path wasn't passed in, we need to auto select it and then read it // from the configuration. diff --git a/extensions/positron-python/src/client/common/utils/async.ts b/extensions/positron-python/src/client/common/utils/async.ts index 67aa070839c..c119d8f19b0 100644 --- a/extensions/positron-python/src/client/common/utils/async.ts +++ b/extensions/positron-python/src/client/common/utils/async.ts @@ -115,9 +115,9 @@ export interface IAsyncIterableIterator extends IAsyncIterator, AsyncItera * An iterator that yields nothing. */ export function iterEmpty(): IAsyncIterableIterator { - return (async function* () { + return ((async function* () { /** No body. */ - })() as unknown as IAsyncIterableIterator; + })() as unknown) as IAsyncIterableIterator; } type NextResult = { index: number } & ( diff --git a/extensions/positron-python/src/client/common/utils/enum.ts b/extensions/positron-python/src/client/common/utils/enum.ts index 1717ea51f5b..78104b48846 100644 --- a/extensions/positron-python/src/client/common/utils/enum.ts +++ b/extensions/positron-python/src/client/common/utils/enum.ts @@ -12,7 +12,7 @@ function getNames(e: any) { } export function getValues(e: any) { - return getObjValues(e).filter((v) => typeof v === 'number') as any as T[]; + return (getObjValues(e).filter((v) => typeof v === 'number') as any) as T[]; } function getObjValues(e: any): (number | string)[] { diff --git a/extensions/positron-python/src/client/common/utils/platform.ts b/extensions/positron-python/src/client/common/utils/platform.ts index 67a5cbbe899..cf3b28e5cc3 100644 --- a/extensions/positron-python/src/client/common/utils/platform.ts +++ b/extensions/positron-python/src/client/common/utils/platform.ts @@ -53,7 +53,7 @@ export function getArchitecture(): Architecture { * Look up the requested env var value (or undefined` if not set). */ export function getEnvironmentVariable(key: string): string | undefined { - return (process.env as any as EnvironmentVariables)[key]; + return ((process.env as any) as EnvironmentVariables)[key]; } /** diff --git a/extensions/positron-python/src/client/common/utils/version.ts b/extensions/positron-python/src/client/common/utils/version.ts index e98fd83f2a6..b3d9ed3d2f4 100644 --- a/extensions/positron-python/src/client/common/utils/version.ts +++ b/extensions/positron-python/src/client/common/utils/version.ts @@ -80,7 +80,7 @@ function copyStrict(info: T): RawBasicVersionInfo { micro: info.micro, }; - const { unnormalized } = info as unknown as RawBasicVersionInfo; + const { unnormalized } = (info as unknown) as RawBasicVersionInfo; if (unnormalized !== undefined) { copied.unnormalized = { major: unnormalized.major, @@ -134,7 +134,7 @@ function validateVersionPart(prop: string, part: number, unnormalized?: ErrorMsg * is responsible for any other properties beyond that. */ function validateBasicVersionInfo(info: T): void { - const raw = info as unknown as RawBasicVersionInfo; + const raw = (info as unknown) as RawBasicVersionInfo; validateVersionPart('major', info.major, raw.unnormalized?.major); validateVersionPart('minor', info.minor, raw.unnormalized?.minor); validateVersionPart('micro', info.micro, raw.unnormalized?.micro); @@ -224,7 +224,7 @@ export function parseBasicVersionInfo(verStr: string const micro = microStr ? parseInt(microStr, 10) : -1; return { // This is effectively normalized. - version: { major, minor, micro } as unknown as T, + version: ({ major, minor, micro } as unknown) as T, before: before || '', after: after || '', }; @@ -388,10 +388,10 @@ export function areSimilarVersions { - (this as any as Record)[`env:${key}`] = ( - this as any as Record - )[`env.${key}`] = process.env[key]; + ((this as any) as Record)[`env:${key}`] = ((this as any) as Record< + string, + string | undefined + >)[`env.${key}`] = process.env[key]; }); workspace = workspace ?? new WorkspaceService(); try { workspace.workspaceFolders?.forEach((folder) => { const basename = Path.basename(folder.uri.fsPath); - (this as any as Record)[`workspaceFolder:${basename}`] = folder.uri.fsPath; - (this as any as Record)[`workspaceFolder:${folder.name}`] = + ((this as any) as Record)[`workspaceFolder:${basename}`] = + folder.uri.fsPath; + ((this as any) as Record)[`workspaceFolder:${folder.name}`] = folder.uri.fsPath; }); } catch { diff --git a/extensions/positron-python/src/client/debugger/extension/adapter/logging.ts b/extensions/positron-python/src/client/debugger/extension/adapter/logging.ts index edfbf621214..907b895170c 100644 --- a/extensions/positron-python/src/client/debugger/extension/adapter/logging.ts +++ b/extensions/positron-python/src/client/debugger/extension/adapter/logging.ts @@ -22,10 +22,7 @@ class DebugSessionLoggingTracker implements DebugAdapterTracker { private stream?: WriteStream; private timer = new StopWatch(); - constructor( - private readonly session: DebugSession, - fileSystem: IFileSystem, - ) { + constructor(private readonly session: DebugSession, fileSystem: IFileSystem) { this.enabled = this.session.configuration.logToFile as boolean; if (this.enabled) { const fileName = `debugger.vscode_${this.session.id}.log`; diff --git a/extensions/positron-python/src/client/debugger/extension/configuration/resolvers/base.ts b/extensions/positron-python/src/client/debugger/extension/configuration/resolvers/base.ts index fb45febdf6d..795d06abf6d 100644 --- a/extensions/positron-python/src/client/debugger/extension/configuration/resolvers/base.ts +++ b/extensions/positron-python/src/client/debugger/extension/configuration/resolvers/base.ts @@ -24,8 +24,7 @@ import { getProgram } from './helper'; @injectable() export abstract class BaseConfigurationResolver - implements IDebugConfigurationResolver -{ + implements IDebugConfigurationResolver { protected pythonPathSource: PythonPathSource = PythonPathSource.launchJson; constructor( diff --git a/extensions/positron-python/src/client/deprecatedProposedApiTypes.ts b/extensions/positron-python/src/client/deprecatedProposedApiTypes.ts index 728fb182125..79b267d5b87 100644 --- a/extensions/positron-python/src/client/deprecatedProposedApiTypes.ts +++ b/extensions/positron-python/src/client/deprecatedProposedApiTypes.ts @@ -59,7 +59,9 @@ export interface DeprecatedProposedAPI { * * If no folder is present, it returns the global setting. * @returns {({ execCommand: string[] | undefined })} */ - getExecutionDetails(resource?: Resource): Promise<{ + getExecutionDetails( + resource?: Resource, + ): Promise<{ /** * E.g of execution commands returned could be, * * `['']` diff --git a/extensions/positron-python/src/client/extension.ts b/extensions/positron-python/src/client/extension.ts index c435a401714..3736954fbf0 100644 --- a/extensions/positron-python/src/client/extension.ts +++ b/extensions/positron-python/src/client/extension.ts @@ -207,9 +207,9 @@ interface IAppShell { function notifyUser(msg: string) { try { - let appShell: IAppShell = window as any as IAppShell; + let appShell: IAppShell = (window as any) as IAppShell; if (activatedServiceContainer) { - appShell = activatedServiceContainer.get(IApplicationShell) as any as IAppShell; + appShell = (activatedServiceContainer.get(IApplicationShell) as any) as IAppShell; } appShell.showErrorMessage(msg).ignoreErrors(); } catch (ex) { diff --git a/extensions/positron-python/src/client/extensionActivation.ts b/extensions/positron-python/src/client/extensionActivation.ts index cbf9e47bb2d..543d2d0b7f4 100644 --- a/extensions/positron-python/src/client/extensionActivation.ts +++ b/extensions/positron-python/src/client/extensionActivation.ts @@ -88,12 +88,15 @@ export async function activateComponents( } export function activateFeatures(ext: ExtensionState, _components: Components): void { - const interpreterQuickPick: IInterpreterQuickPick = - ext.legacyIOC.serviceContainer.get(IInterpreterQuickPick); - const interpreterPathService: IInterpreterPathService = - ext.legacyIOC.serviceContainer.get(IInterpreterPathService); - const interpreterService: IInterpreterService = - ext.legacyIOC.serviceContainer.get(IInterpreterService); + const interpreterQuickPick: IInterpreterQuickPick = ext.legacyIOC.serviceContainer.get( + IInterpreterQuickPick, + ); + const interpreterPathService: IInterpreterPathService = ext.legacyIOC.serviceContainer.get( + IInterpreterPathService, + ); + const interpreterService: IInterpreterService = ext.legacyIOC.serviceContainer.get( + IInterpreterService, + ); const pathUtils = ext.legacyIOC.serviceContainer.get(IPathUtils); registerAllCreateEnvironmentFeatures( ext.disposables, diff --git a/extensions/positron-python/src/client/interpreter/autoSelection/index.ts b/extensions/positron-python/src/client/interpreter/autoSelection/index.ts index a6ab4f7aa67..5ad5362e821 100644 --- a/extensions/positron-python/src/client/interpreter/autoSelection/index.ts +++ b/extensions/positron-python/src/client/interpreter/autoSelection/index.ts @@ -31,11 +31,12 @@ export class InterpreterAutoSelectionService implements IInterpreterAutoSelectio private readonly autoSelectedInterpreterByWorkspace = new Map(); - private globallyPreferredInterpreter: IPersistentState = - this.stateFactory.createGlobalPersistentState( - preferredGlobalInterpreter, - undefined, - ); + private globallyPreferredInterpreter: IPersistentState< + PythonEnvironment | undefined + > = this.stateFactory.createGlobalPersistentState( + preferredGlobalInterpreter, + undefined, + ); constructor( @inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService, diff --git a/extensions/positron-python/src/client/interpreter/configuration/interpreterSelector/commands/base.ts b/extensions/positron-python/src/client/interpreter/configuration/interpreterSelector/commands/base.ts index e55ad051a9f..6307e286dbf 100644 --- a/extensions/positron-python/src/client/interpreter/configuration/interpreterSelector/commands/base.ts +++ b/extensions/positron-python/src/client/interpreter/configuration/interpreterSelector/commands/base.ts @@ -35,7 +35,9 @@ export abstract class BaseInterpreterSelectorCommand implements IExtensionSingle public abstract activate(): Promise; - protected async getConfigTargets(options?: { resetTarget?: boolean }): Promise< + protected async getConfigTargets(options?: { + resetTarget?: boolean; + }): Promise< | { folderUri: Resource; configTarget: ConfigurationTarget; diff --git a/extensions/positron-python/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts b/extensions/positron-python/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts index 837522f4885..8c9656b3feb 100644 --- a/extensions/positron-python/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts +++ b/extensions/positron-python/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts @@ -3,10 +3,7 @@ import { IInterpreterPathService } from '../../../common/types'; import { IPythonPathUpdaterService } from '../types'; export class WorkspaceFolderPythonPathUpdaterService implements IPythonPathUpdaterService { - constructor( - private workspaceFolder: Uri, - private readonly interpreterPathService: IInterpreterPathService, - ) {} + constructor(private workspaceFolder: Uri, private readonly interpreterPathService: IInterpreterPathService) {} public async updatePythonPath(pythonPath: string | undefined): Promise { const pythonPathValue = this.interpreterPathService.inspect(this.workspaceFolder); diff --git a/extensions/positron-python/src/client/interpreter/configuration/services/workspaceUpdaterService.ts b/extensions/positron-python/src/client/interpreter/configuration/services/workspaceUpdaterService.ts index 7d3aa45a854..65bcd0b30e3 100644 --- a/extensions/positron-python/src/client/interpreter/configuration/services/workspaceUpdaterService.ts +++ b/extensions/positron-python/src/client/interpreter/configuration/services/workspaceUpdaterService.ts @@ -3,10 +3,7 @@ import { IInterpreterPathService } from '../../../common/types'; import { IPythonPathUpdaterService } from '../types'; export class WorkspacePythonPathUpdaterService implements IPythonPathUpdaterService { - constructor( - private workspace: Uri, - private readonly interpreterPathService: IInterpreterPathService, - ) {} + constructor(private workspace: Uri, private readonly interpreterPathService: IInterpreterPathService) {} public async updatePythonPath(pythonPath: string | undefined): Promise { const pythonPathValue = this.interpreterPathService.inspect(this.workspace); diff --git a/extensions/positron-python/src/client/interpreter/interpreterService.ts b/extensions/positron-python/src/client/interpreter/interpreterService.ts index 1e968f556cc..e9829d978fb 100644 --- a/extensions/positron-python/src/client/interpreter/interpreterService.ts +++ b/extensions/positron-python/src/client/interpreter/interpreterService.ts @@ -228,8 +228,9 @@ export class InterpreterService implements Disposable, IInterpreterService { // Note the following triggers autoselection if no interpreter is explictly // selected, i.e the value is `python`. // During shutdown we might not be able to get items out of the service container. - const pythonExecutionFactory = - this.serviceContainer.tryGet(IPythonExecutionFactory); + const pythonExecutionFactory = this.serviceContainer.tryGet( + IPythonExecutionFactory, + ); const pythonExecutionService = pythonExecutionFactory ? await pythonExecutionFactory.create({ resource }) : undefined; diff --git a/extensions/positron-python/src/client/logging/index.ts b/extensions/positron-python/src/client/logging/index.ts index 1390e06b4b7..39d5652e100 100644 --- a/extensions/positron-python/src/client/logging/index.ts +++ b/extensions/positron-python/src/client/logging/index.ts @@ -126,7 +126,7 @@ function tracing(log: (t: TraceInfo) => void, run: () => T): T { // If method being wrapped returns a promise then wait for it. if (isPromise(result)) { - (result as unknown as Promise) + ((result as unknown) as Promise) .then((data) => { log({ elapsed: timer.elapsedTime, returnValue: data }); return data; @@ -191,7 +191,7 @@ function logResult(logInfo: LogInfo, traced: TraceInfo, call?: CallInfo) { } } else { logTo(LogLevel.Error, [formatted, traced.err]); - sendTelemetryEvent('ERROR' as unknown as EventName, undefined, undefined, traced.err); + sendTelemetryEvent(('ERROR' as unknown) as EventName, undefined, undefined, traced.err); } } diff --git a/extensions/positron-python/src/client/positron/discoverer.ts b/extensions/positron-python/src/client/positron/discoverer.ts index a14dc8fa503..fec8e8f5d26 100644 --- a/extensions/positron-python/src/client/positron/discoverer.ts +++ b/extensions/positron-python/src/client/positron/discoverer.ts @@ -38,10 +38,8 @@ export async function* pythonRuntimeDiscoverer( // NOTE: We may need to pass a resource to getSettings to support multi-root workspaces const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri; const suggestions = interpreterSelector.getSuggestions(workspaceUri); - let recommendedInterpreter = interpreterSelector.getRecommendedSuggestion( - suggestions, - workspaceUri, - )?.interpreter; + let recommendedInterpreter = interpreterSelector.getRecommendedSuggestion(suggestions, workspaceUri) + ?.interpreter; if (!recommendedInterpreter) { // fallback to active interpreter if we don't have a recommended interpreter recommendedInterpreter = await interpreterService.getActiveInterpreter(workspaceUri); diff --git a/extensions/positron-python/src/client/positron/errorHandler.ts b/extensions/positron-python/src/client/positron/errorHandler.ts index d2141e2f507..1756b73b116 100644 --- a/extensions/positron-python/src/client/positron/errorHandler.ts +++ b/extensions/positron-python/src/client/positron/errorHandler.ts @@ -25,10 +25,7 @@ import { traceWarn } from '../logging'; // https://github.com/microsoft/vscode-languageserver-node/blob/8e625564b531da607859b8cb982abb7cdb2fbe2e/client/src/common/client.ts#L1617 // https://github.com/microsoft/vscode-languageserver-node/blob/4b5f9cf622963dcfbc6129cdc1a570e2bb9f66a4/client/src/common/client.ts#L1639 export class PythonErrorHandler implements ErrorHandler { - constructor( - private readonly _version: string, - private readonly _port: number, - ) {} + constructor(private readonly _version: string, private readonly _port: number) {} public error(error: Error, _message: Message, count: number): ErrorHandlerResult { traceWarn( diff --git a/extensions/positron-python/src/client/positron/manager.ts b/extensions/positron-python/src/client/positron/manager.ts index 94049f79839..1d7513c1fef 100644 --- a/extensions/positron-python/src/client/positron/manager.ts +++ b/extensions/positron-python/src/client/positron/manager.ts @@ -117,8 +117,9 @@ export class PythonRuntimeManager implements IPythonRuntimeManager { traceInfo('createPythonSession: getting service instances'); const configService = this.serviceContainer.get(IConfigurationService); - const environmentVariablesProvider = - this.serviceContainer.get(IEnvironmentVariablesProvider); + const environmentVariablesProvider = this.serviceContainer.get( + IEnvironmentVariablesProvider, + ); // Extract the extra data from the runtime metadata; it contains the // environment ID that was saved when the metadata was created. diff --git a/extensions/positron-python/src/client/positron/session.ts b/extensions/positron-python/src/client/positron/session.ts index 5eedb3a96ef..5a79143c5cf 100644 --- a/extensions/positron-python/src/client/positron/session.ts +++ b/extensions/positron-python/src/client/positron/session.ts @@ -310,8 +310,9 @@ export class PythonRuntimeSession implements positron.LanguageRuntimeSession, vs private async createLsp() { traceInfo(`createPythonSession: resolving LSP services`); - const environmentService = - this.serviceContainer.get(IEnvironmentVariablesProvider); + const environmentService = this.serviceContainer.get( + IEnvironmentVariablesProvider, + ); const outputChannel = this.serviceContainer.get(ILanguageServerOutputChannel); const configService = this.serviceContainer.get(IConfigurationService); const workspaceService = this.serviceContainer.get(IWorkspaceService); diff --git a/extensions/positron-python/src/client/pythonEnvironments/base/info/pythonVersion.ts b/extensions/positron-python/src/client/pythonEnvironments/base/info/pythonVersion.ts index 8fca961862b..589bf4c7b7a 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/base/info/pythonVersion.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/base/info/pythonVersion.ts @@ -235,7 +235,9 @@ function compareVersionRelease(left: PythonVersion, right: PythonVersion): [numb * Remarks: primarily used to convert to old type of environment info. * @deprecated */ -export function toSemverLikeVersion(version: PythonVersion): { +export function toSemverLikeVersion( + version: PythonVersion, +): { raw: string; major: number; minor: number; diff --git a/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts b/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts index 0c63a2b1325..456e8adfa9a 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts @@ -67,10 +67,8 @@ interface IPersistentStorage { /** * Environment info cache using persistent storage to save and retrieve pre-cached env info. */ -export class PythonEnvInfoCache - extends PythonEnvsWatcher - implements IEnvsCollectionCache -{ +export class PythonEnvInfoCache extends PythonEnvsWatcher + implements IEnvsCollectionCache { private envs: PythonEnvInfo[] = []; /** diff --git a/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts b/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts index ec08d02eb7a..a54489e3463 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsCollectionService.ts @@ -54,10 +54,7 @@ export class EnvsCollectionService extends PythonEnvsWatcher { const query: PythonLocatorQuery | undefined = event.providerId diff --git a/extensions/positron-python/src/client/pythonEnvironments/base/locators/wrappers.ts b/extensions/positron-python/src/client/pythonEnvironments/base/locators/wrappers.ts index dbff371fb14..bfaede584f6 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/base/locators/wrappers.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/base/locators/wrappers.ts @@ -62,10 +62,7 @@ export class WorkspaceLocators extends LazyResourceBasedLocator { private readonly roots: Record = {}; - constructor( - private readonly watchRoots: WatchRootsFunc, - private readonly factories: WorkspaceLocatorFactory[], - ) { + constructor(private readonly watchRoots: WatchRootsFunc, private readonly factories: WorkspaceLocatorFactory[]) { super(); this.activate().ignoreErrors(); } diff --git a/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/condaService.ts b/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/condaService.ts index c2a574cd485..049e19380d4 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/condaService.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/condaService.ts @@ -25,8 +25,9 @@ export class CondaService implements ICondaService { ): Promise<{ path: string | undefined; type: 'local' | 'global' } | undefined> { const condaPath = await this.getCondaFileFromInterpreter(interpreterPath, envName); - const activatePath = ( - condaPath ? path.join(path.dirname(condaPath), 'activate') : 'activate' + const activatePath = (condaPath + ? path.join(path.dirname(condaPath), 'activate') + : 'activate' ).fileToCommandArgumentForPythonExt(); // maybe global activate? // try to find the activate script in the global conda root prefix. diff --git a/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/hatch.ts b/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/hatch.ts index 2b8223020a2..6d7a13ea155 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/hatch.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/hatch.ts @@ -23,10 +23,7 @@ export class Hatch { * first argument of spawn() - i.e. it can be a full path, or just a binary name. * @param cwd - The working directory to use as cwd when running hatch. */ - constructor( - public readonly command: string, - private cwd: string, - ) { + constructor(public readonly command: string, private cwd: string) { this.fixCwd(); } diff --git a/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/poetry.ts b/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/poetry.ts index b5ac2055a9f..5e5fa241620 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/poetry.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/common/environmentManagers/poetry.ts @@ -113,10 +113,7 @@ export class Poetry { * first argument of spawn() - i.e. it can be a full path, or just a binary name. * @param cwd - The working directory to use as cwd when running poetry. */ - constructor( - public readonly command: string, - private cwd: string, - ) { + constructor(public readonly command: string, private cwd: string) { this.fixCwd(); } diff --git a/extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts b/extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts index c887472d8f5..927a53923cf 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts @@ -72,10 +72,13 @@ export function registerCreateEnvironmentFeatures( return handleCreateEnvironmentCommand(providers, options); }, ), - registerCommand(Commands.Create_Environment_Button, async (): Promise => { - sendTelemetryEvent(EventName.ENVIRONMENT_BUTTON, undefined, undefined); - await executeCommand(Commands.Create_Environment); - }), + registerCommand( + Commands.Create_Environment_Button, + async (): Promise => { + sendTelemetryEvent(EventName.ENVIRONMENT_BUTTON, undefined, undefined); + await executeCommand(Commands.Create_Environment); + }, + ), // --- Start Positron --- registerCommand(Commands.Get_Create_Environment_Providers, () => { const providers = _createEnvironmentProviders.getAll(); diff --git a/extensions/positron-python/src/client/pythonEnvironments/index.ts b/extensions/positron-python/src/client/pythonEnvironments/index.ts index d08d3ad900b..d3f6166295d 100644 --- a/extensions/positron-python/src/client/pythonEnvironments/index.ts +++ b/extensions/positron-python/src/client/pythonEnvironments/index.ts @@ -220,7 +220,7 @@ function putIntoStorage(storage: IPersistentStorage, envs: Pyth if (e.searchLocation) { // Make TS believe it is string. This is temporary. We need to serialize this in // a custom way. - e.searchLocation = e.searchLocation.toString() as unknown as Uri; + e.searchLocation = (e.searchLocation.toString() as unknown) as Uri; } return e; }), diff --git a/extensions/positron-python/src/client/telemetry/importTracker.ts b/extensions/positron-python/src/client/telemetry/importTracker.ts index ca8914d01f6..e00714d24cb 100644 --- a/extensions/positron-python/src/client/telemetry/importTracker.ts +++ b/extensions/positron-python/src/client/telemetry/importTracker.ts @@ -38,8 +38,7 @@ Things we are ignoring the following for simplicity/performance: - Non-standard whitespace separators within the import statement (i.e. more than a single space, tabs) */ -const ImportRegEx = - /^\s*(from (?\w+)(?:\.\w+)* import \w+(?:, \w+)*(?: as \w+)?|import (?\w+(?:, \w+)*)(?: as \w+)?)$/; +const ImportRegEx = /^\s*(from (?\w+)(?:\.\w+)* import \w+(?:, \w+)*(?: as \w+)?|import (?\w+(?:, \w+)*)(?: as \w+)?)$/; const MAX_DOCUMENT_LINES = 1000; // Capture isTestExecution on module load so that a test can turn it off and still diff --git a/extensions/positron-python/src/client/tensorBoard/helpers.ts b/extensions/positron-python/src/client/tensorBoard/helpers.ts index de13ef910f1..3efb6aca04f 100644 --- a/extensions/positron-python/src/client/tensorBoard/helpers.ts +++ b/extensions/positron-python/src/client/tensorBoard/helpers.ts @@ -10,11 +10,9 @@ import { noop } from '../common/utils/misc'; // matches the 'main' module. // RegEx to match `import torch.profiler` or `from torch import profiler` -export const TorchProfilerImportRegEx = - /^\s*(?:import (?:(\w+, )*torch\.profiler(, \w+)*))|(?:from torch import (?:(\w+, )*profiler(, \w+)*))/; +export const TorchProfilerImportRegEx = /^\s*(?:import (?:(\w+, )*torch\.profiler(, \w+)*))|(?:from torch import (?:(\w+, )*profiler(, \w+)*))/; // RegEx to match `from torch.utils import tensorboard`, `import torch.utils.tensorboard`, `import tensorboardX`, `import tensorboard` -const TensorBoardImportRegEx = - /^\s*(?:from torch\.utils\.tensorboard import \w+)|(?:from torch\.utils import (?:(\w+, )*tensorboard(, \w+)*))|(?:from tensorboardX import \w+)|(?:import (\w+, )*((torch\.utils\.tensorboard)|(tensorboardX)|(tensorboard))(, \w+)*)/; +const TensorBoardImportRegEx = /^\s*(?:from torch\.utils\.tensorboard import \w+)|(?:from torch\.utils import (?:(\w+, )*tensorboard(, \w+)*))|(?:from tensorboardX import \w+)|(?:import (\w+, )*((torch\.utils\.tensorboard)|(tensorboardX)|(tensorboard))(, \w+)*)/; export function containsTensorBoardImport(lines: (string | undefined)[]): boolean { try { diff --git a/extensions/positron-python/src/client/testing/common/runner.ts b/extensions/positron-python/src/client/testing/common/runner.ts index d3b9dc0ded5..b6e6f2fb3b2 100644 --- a/extensions/positron-python/src/client/testing/common/runner.ts +++ b/extensions/positron-python/src/client/testing/common/runner.ts @@ -58,8 +58,9 @@ async function run(serviceContainer: IServiceContainer, testProvider: TestProvid executionService.execModuleObservable(executionInfo.moduleName!, executionInfo.args, options), ); } else { - const pythonToolsExecutionService = - serviceContainer.get(IPythonToolExecutionService); + const pythonToolsExecutionService = serviceContainer.get( + IPythonToolExecutionService, + ); promise = pythonToolsExecutionService.execObservable(executionInfo, spawnOptions, options.workspaceFolder); } diff --git a/extensions/positron-python/src/client/testing/testController/common/resultResolver.ts b/extensions/positron-python/src/client/testing/testController/common/resultResolver.ts index 262897e1523..16ee79371b3 100644 --- a/extensions/positron-python/src/client/testing/testController/common/resultResolver.ts +++ b/extensions/positron-python/src/client/testing/testController/common/resultResolver.ts @@ -36,11 +36,7 @@ export class PythonResultResolver implements ITestResultResolver { public subTestStats: Map = new Map(); - constructor( - testController: TestController, - testProvider: TestProvider, - private workspaceUri: Uri, - ) { + constructor(testController: TestController, testProvider: TestProvider, private workspaceUri: Uri) { this.testController = testController; this.testProvider = testProvider; diff --git a/extensions/positron-python/src/test/activation/activationManager.unit.test.ts b/extensions/positron-python/src/test/activation/activationManager.unit.test.ts index 315a4e3c6fb..6ee2572214b 100644 --- a/extensions/positron-python/src/test/activation/activationManager.unit.test.ts +++ b/extensions/positron-python/src/test/activation/activationManager.unit.test.ts @@ -180,8 +180,8 @@ suite('Activation Manager', () => { const disposable2 = typemoq.Mock.ofType(); when(workspaceService.onDidChangeWorkspaceFolders).thenReturn(() => disposable.object); when(workspaceService.workspaceFolders).thenReturn([ - 1 as unknown as WorkspaceFolder, - 2 as unknown as WorkspaceFolder, + (1 as unknown) as WorkspaceFolder, + (2 as unknown) as WorkspaceFolder, ]); const eventDef = () => disposable2.object; documentManager @@ -209,8 +209,8 @@ suite('Activation Manager', () => { const disposable2 = typemoq.Mock.ofType(); when(workspaceService.onDidChangeWorkspaceFolders).thenReturn(() => disposable.object); when(workspaceService.workspaceFolders).thenReturn([ - 1 as unknown as WorkspaceFolder, - 2 as unknown as WorkspaceFolder, + (1 as unknown) as WorkspaceFolder, + (2 as unknown) as WorkspaceFolder, ]); const eventDef = () => disposable2.object; documentManager @@ -328,7 +328,7 @@ suite('Activation Manager', () => { languageId: 'NOT PYTHON', }; - managerTest.onDocOpened(doc as unknown as TextDocument); + managerTest.onDocOpened((doc as unknown) as TextDocument); verify(workspaceService.getWorkspaceFolderIdentifier(doc.uri, anything())).never(); }); @@ -339,7 +339,7 @@ suite('Activation Manager', () => { }; when(workspaceService.getWorkspaceFolderIdentifier(doc.uri, anything())).thenReturn(''); - managerTest.onDocOpened(doc as unknown as TextDocument); + managerTest.onDocOpened((doc as unknown) as TextDocument); verify(workspaceService.getWorkspaceFolderIdentifier(doc.uri, anything())).once(); verify(workspaceService.getWorkspaceFolder(doc.uri)).once(); @@ -353,7 +353,7 @@ suite('Activation Manager', () => { when(workspaceService.getWorkspaceFolderIdentifier(doc.uri, anything())).thenReturn('key'); managerTest.activatedWorkspaces.add('key'); - managerTest.onDocOpened(doc as unknown as TextDocument); + managerTest.onDocOpened((doc as unknown) as TextDocument); verify(workspaceService.getWorkspaceFolderIdentifier(doc.uri, anything())).once(); verify(workspaceService.getWorkspaceFolder(doc.uri)).never(); diff --git a/extensions/positron-python/src/test/activation/jedi/jediAnalysisOptions.unit.test.ts b/extensions/positron-python/src/test/activation/jedi/jediAnalysisOptions.unit.test.ts index 01a1ffba1ac..3456a625272 100644 --- a/extensions/positron-python/src/test/activation/jedi/jediAnalysisOptions.unit.test.ts +++ b/extensions/positron-python/src/test/activation/jedi/jediAnalysisOptions.unit.test.ts @@ -33,10 +33,7 @@ suite('Jedi LSP - analysis Options', () => { public ownedResources = new Set(); - constructor( - folder: string, - public index: number = 0, - ) { + constructor(folder: string, public index: number = 0) { this.uri = Uri.file(folder); this.name = folder; } diff --git a/extensions/positron-python/src/test/activation/partialModeStatus.unit.test.ts b/extensions/positron-python/src/test/activation/partialModeStatus.unit.test.ts index 67fb66e9014..12e4b6fc0c5 100644 --- a/extensions/positron-python/src/test/activation/partialModeStatus.unit.test.ts +++ b/extensions/positron-python/src/test/activation/partialModeStatus.unit.test.ts @@ -20,15 +20,15 @@ suite('Partial Mode Status', async () => { let vscodeMock: typeof vscodeTypes; setup(() => { workspaceService = typemoq.Mock.ofType(); - languageItem = { + languageItem = ({ name: '', severity: 2, text: '', detail: undefined, command: undefined, - } as unknown as LanguageStatusItem; + } as unknown) as LanguageStatusItem; actualSelector = undefined; - vscodeMock = { + vscodeMock = ({ languages: { createLanguageStatusItem: (_: string, selector: DocumentSelector) => { actualSelector = selector; @@ -43,7 +43,7 @@ suite('Partial Mode Status', async () => { Uri: { parse: (s: string) => s, }, - } as unknown as typeof vscodeTypes; + } as unknown) as typeof vscodeTypes; rewiremock.enable(); rewiremock('vscode').with(vscodeMock); }); @@ -78,7 +78,7 @@ suite('Partial Mode Status', async () => { assert.deepEqual(actualSelector!, { language: 'python', }); - assert.deepEqual(languageItem, { + assert.deepEqual(languageItem, ({ name: LanguageService.statusItem.name, severity: vscodeMock.LanguageStatusSeverity.Warning, text: LanguageService.statusItem.text, @@ -88,7 +88,7 @@ suite('Partial Mode Status', async () => { command: 'vscode.open', arguments: ['https://aka.ms/AAdzyh4'], }, - } as unknown as LanguageStatusItem); + } as unknown) as LanguageStatusItem); }); test('Expected status item is created if workspace is virtual', async () => { @@ -104,7 +104,7 @@ suite('Partial Mode Status', async () => { assert.deepEqual(actualSelector!, { language: 'python', }); - assert.deepEqual(languageItem, { + assert.deepEqual(languageItem, ({ name: LanguageService.statusItem.name, severity: vscodeMock.LanguageStatusSeverity.Warning, text: LanguageService.statusItem.text, @@ -114,7 +114,7 @@ suite('Partial Mode Status', async () => { command: 'vscode.open', arguments: ['https://aka.ms/AAdzyh4'], }, - } as unknown as LanguageStatusItem); + } as unknown) as LanguageStatusItem); }); test('Expected status item is created if workspace is both virtual and untrusted', async () => { @@ -130,7 +130,7 @@ suite('Partial Mode Status', async () => { assert.deepEqual(actualSelector!, { language: 'python', }); - assert.deepEqual(languageItem, { + assert.deepEqual(languageItem, ({ name: LanguageService.statusItem.name, severity: vscodeMock.LanguageStatusSeverity.Warning, text: LanguageService.statusItem.text, @@ -140,6 +140,6 @@ suite('Partial Mode Status', async () => { command: 'vscode.open', arguments: ['https://aka.ms/AAdzyh4'], }, - } as unknown as LanguageStatusItem); + } as unknown) as LanguageStatusItem); }); }); diff --git a/extensions/positron-python/src/test/application/diagnostics/checks/jediPython27NotSupported.unit.test.ts b/extensions/positron-python/src/test/application/diagnostics/checks/jediPython27NotSupported.unit.test.ts index f3a6c7db132..f457878da3b 100644 --- a/extensions/positron-python/src/test/application/diagnostics/checks/jediPython27NotSupported.unit.test.ts +++ b/extensions/positron-python/src/test/application/diagnostics/checks/jediPython27NotSupported.unit.test.ts @@ -34,22 +34,24 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { suite('Diagnostics', () => { const resource = Uri.file('test.py'); - function createConfigurationAndWorkspaceServices(languageServer: LanguageServerType): { + function createConfigurationAndWorkspaceServices( + languageServer: LanguageServerType, + ): { configurationService: IConfigurationService; workspaceService: IWorkspaceService; } { - const configurationService = { + const configurationService = ({ getSettings: () => ({ languageServer }), updateSetting: () => Promise.resolve(), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; - const workspaceService = { + const workspaceService = ({ getConfiguration: () => ({ inspect: () => ({ workspaceValue: languageServer, }), }), - } as unknown as IWorkspaceService; + } as unknown) as IWorkspaceService; return { configurationService, workspaceService }; } @@ -71,9 +73,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { ); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -96,9 +98,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { ); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -128,9 +130,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { ); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -162,9 +164,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { ); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -196,9 +198,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { ); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -228,9 +230,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { ); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -266,10 +268,10 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { } as IInterpreterService; setup(() => { - serviceContainer = { + serviceContainer = ({ get: (serviceIdentifier: symbol) => services[serviceIdentifier.toString()] as IWorkspaceService, tryGet: () => ({}), - } as unknown as IServiceContainer; + } as unknown) as IServiceContainer; workspaceService = new WorkspaceService(); services = { @@ -280,9 +282,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { updateSettingStub = sinon.stub(ConfigurationService.prototype, 'updateSetting'); const getSettingsStub = sinon.stub(ConfigurationService.prototype, 'getSettings'); - getSettingsStub.returns({ + getSettingsStub.returns(({ getSettings: () => ({ languageServer: LanguageServerType.Jedi }), - } as unknown as IPythonSettings); + } as unknown) as IPythonSettings); }); teardown(() => { @@ -298,9 +300,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { const configurationService = new ConfigurationService(serviceContainer); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -329,9 +331,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { const configurationService = new ConfigurationService(serviceContainer); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -360,9 +362,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { const configurationService = new ConfigurationService(serviceContainer); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -385,9 +387,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { const configurationService = new ConfigurationService(serviceContainer); const service = new JediPython27NotSupportedDiagnosticService( - { + ({ get: () => ({}), - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, interpreterService, workspaceService, configurationService, @@ -432,7 +434,7 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { setup(() => { services = { 'Symbol(IDiagnosticsCommandFactory)': { - createCommand: () => ({}) as IDiagnosticCommand, + createCommand: () => ({} as IDiagnosticCommand), }, }; serviceContainer = { @@ -466,9 +468,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { test('Handling a diagnostic that should be ignored does not display a prompt', async () => { const diagnosticHandlerService = new DiagnosticCommandPromptHandlerService(serviceContainer); - services['Symbol(IDiagnosticFilterService)'] = { + services['Symbol(IDiagnosticFilterService)'] = ({ shouldIgnoreDiagnostic: async () => Promise.resolve(true), - } as unknown as IDiagnosticFilterService; + } as unknown) as IDiagnosticFilterService; const service = new TestJediPython27NotSupportedDiagnosticService( serviceContainer, @@ -488,9 +490,9 @@ suite('Application Diagnostics - Jedi with Python 2.7 deprecated', () => { const diagnosticHandlerService = new DiagnosticCommandPromptHandlerService(serviceContainer); const configurationService = new ConfigurationService(serviceContainer); - services['Symbol(IDiagnosticFilterService)'] = { + services['Symbol(IDiagnosticFilterService)'] = ({ shouldIgnoreDiagnostic: () => Promise.resolve(false), - } as unknown as IDiagnosticFilterService; + } as unknown) as IDiagnosticFilterService; const service = new TestJediPython27NotSupportedDiagnosticService( serviceContainer, diff --git a/extensions/positron-python/src/test/application/diagnostics/checks/macPythonInterpreter.unit.test.ts b/extensions/positron-python/src/test/application/diagnostics/checks/macPythonInterpreter.unit.test.ts index 170ad4c7004..ba2436d0ffe 100644 --- a/extensions/positron-python/src/test/application/diagnostics/checks/macPythonInterpreter.unit.test.ts +++ b/extensions/positron-python/src/test/application/diagnostics/checks/macPythonInterpreter.unit.test.ts @@ -181,8 +181,8 @@ suite('Application Diagnostics - Checks Mac Python Interpreter', () => { DiagnosticCodes.MacInterpreterSelected, undefined, ); - const cmd = {} as any as IDiagnosticCommand; - const cmdIgnore = {} as any as IDiagnosticCommand; + const cmd = ({} as any) as IDiagnosticCommand; + const cmdIgnore = ({} as any) as IDiagnosticCommand; let messagePrompt: MessageCommandPrompt | undefined; messageHandler .setup((i) => i.handle(typemoq.It.isValue(diagnostic), typemoq.It.isAny())) diff --git a/extensions/positron-python/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts b/extensions/positron-python/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts index a8b4e10a1ec..fabef52efbd 100644 --- a/extensions/positron-python/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts +++ b/extensions/positron-python/src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts @@ -115,7 +115,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { .setup((s) => s.get(typemoq.It.isValue(IInterpreterPathService))) .returns(() => interpreterPathService.object); configService = typemoq.Mock.ofType(); - configService.setup((c) => c.getSettings()).returns(() => ({ pythonPath: 'pythonPath' }) as any); + configService.setup((c) => c.getSettings()).returns(() => ({ pythonPath: 'pythonPath' } as any)); serviceContainer .setup((s) => s.get(typemoq.It.isValue(IConfigurationService))) .returns(() => configService.object); @@ -163,7 +163,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { interpreterService.setup((i) => i.hasInterpreters()).returns(() => Promise.resolve(true)); interpreterService .setup((i) => i.getActiveInterpreter(typemoq.It.isAny())) - .returns(() => Promise.resolve({ path: 'interpreterpath' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: 'interpreterpath' } as unknown) as PythonEnvironment)); const result2 = await triggerFunction!(undefined); expect(result2).to.equal(true); }); @@ -374,7 +374,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { test('Handling comspec diagnostic should launch expected browser link', async () => { const diagnostic = new DefaultShellDiagnostic(DiagnosticCodes.InvalidComspecDiagnostic, undefined); - const cmd = {} as any as IDiagnosticCommand; + const cmd = ({} as any) as IDiagnosticCommand; let messagePrompt: MessageCommandPrompt | undefined; messageHandler .setup((i) => i.handle(typemoq.It.isValue(diagnostic), typemoq.It.isAny())) @@ -409,7 +409,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { test('Handling incomplete path diagnostic should launch expected browser link', async () => { const diagnostic = new DefaultShellDiagnostic(DiagnosticCodes.IncompletePathVarDiagnostic, undefined); - const cmd = {} as any as IDiagnosticCommand; + const cmd = ({} as any) as IDiagnosticCommand; let messagePrompt: MessageCommandPrompt | undefined; messageHandler .setup((i) => i.handle(typemoq.It.isValue(diagnostic), typemoq.It.isAny())) @@ -444,7 +444,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { test('Handling default shell error diagnostic should launch expected browser link', async () => { const diagnostic = new DefaultShellDiagnostic(DiagnosticCodes.DefaultShellErrorDiagnostic, undefined); - const cmd = {} as any as IDiagnosticCommand; + const cmd = ({} as any) as IDiagnosticCommand; let messagePrompt: MessageCommandPrompt | undefined; messageHandler .setup((i) => i.handle(typemoq.It.isValue(diagnostic), typemoq.It.isAny())) @@ -483,7 +483,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { undefined, workspaceService.object, ); - const cmd = {} as any as IDiagnosticCommand; + const cmd = ({} as any) as IDiagnosticCommand; let messagePrompt: MessageCommandPrompt | undefined; messageHandler .setup((i) => i.handle(typemoq.It.isValue(diagnostic), typemoq.It.isAny())) @@ -523,7 +523,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { undefined, workspaceService.object, ); - const cmd = {} as any as IDiagnosticCommand; + const cmd = ({} as any) as IDiagnosticCommand; let messagePrompt: MessageCommandPrompt | undefined; messageHandler .setup((i) => i.handle(typemoq.It.isValue(diagnostic), typemoq.It.isAny())) @@ -555,7 +555,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { }); test('Handling an empty diagnostic should not show a message nor return a command', async () => { const diagnostics: IDiagnostic[] = []; - const cmd = {} as any as IDiagnosticCommand; + const cmd = ({} as any) as IDiagnosticCommand; messageHandler .setup((i) => i.handle(typemoq.It.isAny(), typemoq.It.isAny())) @@ -585,10 +585,10 @@ suite('Application Diagnostics - Checks Python Interpreter', () => { undefined, workspaceService.object, ); - const cmd = {} as any as IDiagnosticCommand; - const diagnosticServiceMock = typemoq.Mock.ofInstance( - diagnosticService, - ) as any as typemoq.IMock; + const cmd = ({} as any) as IDiagnosticCommand; + const diagnosticServiceMock = (typemoq.Mock.ofInstance(diagnosticService) as any) as typemoq.IMock< + InvalidPythonInterpreterService + >; diagnosticServiceMock.setup((f) => f.canHandle(typemoq.It.isAny())).returns(() => Promise.resolve(false)); messageHandler diff --git a/extensions/positron-python/src/test/common.ts b/extensions/positron-python/src/test/common.ts index bbde6b367f6..bbf48f0e14c 100644 --- a/extensions/positron-python/src/test/common.ts +++ b/extensions/positron-python/src/test/common.ts @@ -109,13 +109,13 @@ export const resetGlobalInterpreterPathSetting = async () => retryAsync(restoreG async function restoreGlobalInterpreterPathSetting(): Promise { const vscode = require('vscode') as typeof import('vscode'); - const pythonConfig = vscode.workspace.getConfiguration('python', null as any as Uri); + const pythonConfig = vscode.workspace.getConfiguration('python', (null as any) as Uri); await pythonConfig.update('defaultInterpreterPath', undefined, true); await disposePythonSettings(); } async function setGlobalPathToInterpreter(pythonPath?: string): Promise { const vscode = require('vscode') as typeof import('vscode'); - const pythonConfig = vscode.workspace.getConfiguration('python', null as any as Uri); + const pythonConfig = vscode.workspace.getConfiguration('python', (null as any) as Uri); await pythonConfig.update('defaultInterpreterPath', pythonPath, true); await disposePythonSettings(); } @@ -200,7 +200,7 @@ async function setPythonPathInWorkspace( } async function restoreGlobalPythonPathSetting(): Promise { const vscode = require('vscode') as typeof import('vscode'); - const pythonConfig = vscode.workspace.getConfiguration('python', null as any as Uri); + const pythonConfig = vscode.workspace.getConfiguration('python', (null as any) as Uri); await Promise.all([ pythonConfig.update('defaultInterpreterPath', undefined, true), pythonConfig.update('defaultInterpreterPath', undefined, true), @@ -544,11 +544,7 @@ export class TestEventHandler implements IDisposable private readonly handler: IDisposable; private readonly handledEvents: any[] = []; - constructor( - event: Event, - private readonly eventNameForErrorMessages: string, - disposables: IDisposable[] = [], - ) { + constructor(event: Event, private readonly eventNameForErrorMessages: string, disposables: IDisposable[] = []) { disposables.push(this); this.handler = event(this.listener, this); } diff --git a/extensions/positron-python/src/test/common/application/commands/createNewFileCommand.unit.test.ts b/extensions/positron-python/src/test/common/application/commands/createNewFileCommand.unit.test.ts index 75f3c94ea94..c50c7f72914 100644 --- a/extensions/positron-python/src/test/common/application/commands/createNewFileCommand.unit.test.ts +++ b/extensions/positron-python/src/test/common/application/commands/createNewFileCommand.unit.test.ts @@ -28,7 +28,7 @@ suite('Create New Python File Commmand', () => { [], ); when(workspaceService.openTextDocument(deepEqual({ language: 'python' }))).thenReturn( - Promise.resolve({} as unknown as TextDocument), + Promise.resolve(({} as unknown) as TextDocument), ); await createNewFileCommandHandler.activate(); }); diff --git a/extensions/positron-python/src/test/common/application/commands/reportIssueCommand.unit.test.ts b/extensions/positron-python/src/test/common/application/commands/reportIssueCommand.unit.test.ts index 710ca4757ad..2a35a6306cd 100644 --- a/extensions/positron-python/src/test/common/application/commands/reportIssueCommand.unit.test.ts +++ b/extensions/positron-python/src/test/common/application/commands/reportIssueCommand.unit.test.ts @@ -56,10 +56,10 @@ suite('Report Issue Command', () => { languageServer: LanguageServerType.Node, }), ); - const interpreter = { + const interpreter = ({ envType: EnvironmentType.Venv, version: { raw: '3.9.0' }, - } as unknown as PythonEnvironment; + } as unknown) as PythonEnvironment; when(interpreterService.getActiveInterpreter()).thenResolve(interpreter); when(configurationService.getSettings()).thenReturn({ experiments: { diff --git a/extensions/positron-python/src/test/common/configSettings.test.ts b/extensions/positron-python/src/test/common/configSettings.test.ts index 0cd23859dba..8630835081e 100644 --- a/extensions/positron-python/src/test/common/configSettings.test.ts +++ b/extensions/positron-python/src/test/common/configSettings.test.ts @@ -15,7 +15,7 @@ suite('Configuration Settings', () => { test('Check Values', (done) => { const systemVariables: SystemVariables = new SystemVariables(undefined, workspaceRoot); - const pythonConfig = vscode.workspace.getConfiguration('python', null as any as vscode.Uri); + const pythonConfig = vscode.workspace.getConfiguration('python', (null as any) as vscode.Uri); const pythonSettings = getExtensionSettings(vscode.Uri.file(workspaceRoot)); Object.keys(pythonSettings).forEach((key) => { let settingValue = pythonConfig.get(key, 'Not a config'); diff --git a/extensions/positron-python/src/test/common/experiments/service.unit.test.ts b/extensions/positron-python/src/test/common/experiments/service.unit.test.ts index 835cc37356d..00aba3fc1ea 100644 --- a/extensions/positron-python/src/test/common/experiments/service.unit.test.ts +++ b/extensions/positron-python/src/test/common/experiments/service.unit.test.ts @@ -180,9 +180,9 @@ suite('Experimentation service', () => { }); getTreatmentVariable = sinon.stub().returns(true); - sinon.stub(tasClient, 'getExperimentationService').returns({ + sinon.stub(tasClient, 'getExperimentationService').returns(({ getTreatmentVariable, - } as unknown as expService.IExperimentationService); + } as unknown) as expService.IExperimentationService); configureApplicationEnvironment('stable', extensionVersion); }); @@ -218,9 +218,9 @@ suite('Experimentation service', () => { // Control group returns false. getTreatmentVariable = sinon.stub().returns(false); - sinon.stub(tasClient, 'getExperimentationService').returns({ + sinon.stub(tasClient, 'getExperimentationService').returns(({ getTreatmentVariable, - } as unknown as expService.IExperimentationService); + } as unknown) as expService.IExperimentationService); configureApplicationEnvironment('stable', extensionVersion); @@ -364,9 +364,9 @@ suite('Experimentation service', () => { setup(() => { getTreatmentVariableStub = sinon.stub().returns(Promise.resolve('value')); - sinon.stub(tasClient, 'getExperimentationService').returns({ + sinon.stub(tasClient, 'getExperimentationService').returns(({ getTreatmentVariable: getTreatmentVariableStub, - } as unknown as expService.IExperimentationService); + } as unknown) as expService.IExperimentationService); configureApplicationEnvironment('stable', extensionVersion); }); diff --git a/extensions/positron-python/src/test/common/installer/pipEnvInstaller.unit.test.ts b/extensions/positron-python/src/test/common/installer/pipEnvInstaller.unit.test.ts index fa47c640010..25b1b910daa 100644 --- a/extensions/positron-python/src/test/common/installer/pipEnvInstaller.unit.test.ts +++ b/extensions/positron-python/src/test/common/installer/pipEnvInstaller.unit.test.ts @@ -80,7 +80,7 @@ suite('PipEnv installer', async () => { workspaceService .setup((w) => w.getWorkspaceFolder(resource)) - .returns(() => ({ uri: { fsPath: workspaceFolder } }) as any); + .returns(() => ({ uri: { fsPath: workspaceFolder } } as any)); const result = await pipEnvInstaller.isSupported(resource); expect(result).to.equal(true, 'Should be true'); }); @@ -93,7 +93,7 @@ suite('PipEnv installer', async () => { workspaceService .setup((w) => w.getWorkspaceFolder(resource)) - .returns(() => ({ uri: { fsPath: workspaceFolder } }) as any); + .returns(() => ({ uri: { fsPath: workspaceFolder } } as any)); const result = await pipEnvInstaller.isSupported(resource); expect(result).to.equal(false, 'Should be false'); }); @@ -106,7 +106,7 @@ suite('PipEnv installer', async () => { workspaceService .setup((w) => w.getWorkspaceFolder(resource)) - .returns(() => ({ uri: { fsPath: workspaceFolder } }) as any); + .returns(() => ({ uri: { fsPath: workspaceFolder } } as any)); const result = await pipEnvInstaller.isSupported(resource); expect(result).to.equal(false, 'Should be false'); }); diff --git a/extensions/positron-python/src/test/common/installer/pipInstaller.unit.test.ts b/extensions/positron-python/src/test/common/installer/pipInstaller.unit.test.ts index 4bbac0017ea..7b7af714f7f 100644 --- a/extensions/positron-python/src/test/common/installer/pipInstaller.unit.test.ts +++ b/extensions/positron-python/src/test/common/installer/pipInstaller.unit.test.ts @@ -30,7 +30,7 @@ suite('xPip installer', async () => { .returns(() => interpreterService.object); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(interpreter as unknown as PythonEnvironment)); + .returns(() => Promise.resolve((interpreter as unknown) as PythonEnvironment)); serviceContainer .setup((c) => c.get(TypeMoq.It.isValue(IPythonExecutionFactory))) .returns(() => pythonExecutionFactory.object); @@ -88,7 +88,7 @@ suite('xPip installer', async () => { interpreterService.reset(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(condaInterpreter as unknown as PythonEnvironment)); + .returns(() => Promise.resolve((condaInterpreter as unknown) as PythonEnvironment)); const result = await pipInstaller.isSupported(resource); expect(result).to.equal(false); }); diff --git a/extensions/positron-python/src/test/common/interpreterPathService.unit.test.ts b/extensions/positron-python/src/test/common/interpreterPathService.unit.test.ts index f4598ea463d..58a34b3cbcd 100644 --- a/extensions/positron-python/src/test/common/interpreterPathService.unit.test.ts +++ b/extensions/positron-python/src/test/common/interpreterPathService.unit.test.ts @@ -69,7 +69,7 @@ suite('Interpreter Path Service', async () => { () => ({ globalValue: interpreterPath, - }) as any, + } as any), ); workspaceConfig .setup((w) => w.update('defaultInterpreterPath', interpreterPath, true)) @@ -90,7 +90,7 @@ suite('Interpreter Path Service', async () => { () => ({ globalValue: 'storedValue', - }) as any, + } as any), ); workspaceConfig .setup((w) => w.update('defaultInterpreterPath', interpreterPath, true)) @@ -279,7 +279,7 @@ suite('Interpreter Path Service', async () => { () => ({ globalValue: 'default/path/to/interpreter', - }) as any, + } as any), ); const persistentState = TypeMoq.Mock.ofType>(); workspaceService.setup((w) => w.workspaceFolders).returns(() => undefined); @@ -311,7 +311,7 @@ suite('Interpreter Path Service', async () => { () => ({ globalValue: 'default/path/to/interpreter', - }) as any, + } as any), ); const workspaceFolderPersistentState = TypeMoq.Mock.ofType>(); workspaceService.setup((w) => w.workspaceFolders).returns(() => undefined); @@ -347,7 +347,7 @@ suite('Interpreter Path Service', async () => { () => ({ globalValue: 'default/path/to/interpreter', - }) as any, + } as any), ); const workspaceFolderPersistentState = TypeMoq.Mock.ofType>(); const workspacePersistentState = TypeMoq.Mock.ofType>(); @@ -389,7 +389,7 @@ suite('Interpreter Path Service', async () => { globalValue: 'default/path/to/interpreter', workspaceValue: 'defaultWorkspaceValue', workspaceFolderValue: 'defaultWorkspaceFolderValue', - }) as any, + } as any), ); const workspaceFolderPersistentState = TypeMoq.Mock.ofType>(); const workspacePersistentState = TypeMoq.Mock.ofType>(); diff --git a/extensions/positron-python/src/test/common/platform/filesystem.unit.test.ts b/extensions/positron-python/src/test/common/platform/filesystem.unit.test.ts index 054048cb6f6..5a6f802029b 100644 --- a/extensions/positron-python/src/test/common/platform/filesystem.unit.test.ts +++ b/extensions/positron-python/src/test/common/platform/filesystem.unit.test.ts @@ -238,7 +238,7 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(tgt)) // Provide the target's parent. .returns(() => 'x/y'); raw.setup((r) => r.stat(Uri('x/y'))) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); raw.setup((r) => r.rename(Uri(src), Uri(tgt), { overwrite: false })) // expect the specific filename .returns(() => Promise.resolve()); @@ -253,12 +253,12 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(tgt)) // Provide the target's parent. .returns(() => 'x/y'); raw.setup((r) => r.stat(Uri('x/y'))) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); const err = vscode.FileSystemError.FileExists('...'); raw.setup((r) => r.rename(Uri(src), Uri(tgt), { overwrite: false })) // expect the specific filename .returns(() => Promise.reject(err)); raw.setup((r) => r.stat(Uri(tgt))) // It's a file. - .returns(() => Promise.resolve({ type: FileType.File } as unknown as FileStat)); + .returns(() => Promise.resolve(({ type: FileType.File } as unknown) as FileStat)); raw.setup((r) => r.rename(Uri(src), Uri(tgt), { overwrite: true })) // expect the specific filename .returns(() => Promise.resolve()); @@ -273,7 +273,7 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(tgt)) // Provide the target's parent. .returns(() => 'x/y'); raw.setup((r) => r.stat(Uri('x/y'))) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); raw.setup((r) => r.rename(Uri(src), Uri(tgt), { overwrite: false })) // expect the specific filename .returns(() => Promise.resolve()); @@ -288,12 +288,12 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(tgt)) // Provide the target's parent. .returns(() => 'x/y'); raw.setup((r) => r.stat(Uri('x/y'))) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); const err = vscode.FileSystemError.FileExists('...'); raw.setup((r) => r.rename(Uri(src), Uri(tgt), { overwrite: false })) // expect the specific filename .returns(() => Promise.reject(err)); raw.setup((r) => r.stat(Uri(tgt))) // It's a directory. - .returns(() => Promise.resolve({ type: FileType.Directory } as unknown as FileStat)); + .returns(() => Promise.resolve(({ type: FileType.Directory } as unknown) as FileStat)); const promise = filesystem.move(src, tgt); @@ -307,13 +307,13 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(tgt)) // Provide the target's parent. .returns(() => 'x/y'); raw.setup((r) => r.stat(Uri('x/y'))) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); const err = vscode.FileSystemError.FileExists('...'); raw.setup((r) => r.rename(Uri(src), Uri(tgt), { overwrite: false })) // expect the specific filename .returns(() => Promise.reject(err)); raw.setup((r) => r.stat(Uri(tgt))) // It's a symlink. .returns(() => - Promise.resolve({ type: FileType.SymbolicLink | FileType.Directory } as unknown as FileStat), + Promise.resolve(({ type: FileType.SymbolicLink | FileType.Directory } as unknown) as FileStat), ); raw.setup((r) => r.rename(Uri(src), Uri(tgt), { overwrite: true })) // expect the specific filename .returns(() => Promise.resolve()); @@ -340,7 +340,7 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(TypeMoq.It.isAny())) // Provide the target's parent. .returns(() => ''); raw.setup((r) => r.stat(TypeMoq.It.isAny())) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); const err = new Error('oops!'); raw.setup((r) => r.rename(TypeMoq.It.isAny(), TypeMoq.It.isAny(), { overwrite: false })) // We don't care about the filename. .throws(err); @@ -455,7 +455,7 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(tgt)) // Provide the target's parent. .returns(() => 'x/y/z'); raw.setup((r) => r.stat(Uri('x/y/z'))) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); raw.setup((r) => r.copy(Uri(src), Uri(tgt), { overwrite: true })) // Expect the specific args. .returns(() => Promise.resolve()); @@ -481,7 +481,7 @@ suite('Raw FileSystem', () => { raw.setup((r) => r.dirname(TypeMoq.It.isAny())) // Provide the target's parent. .returns(() => ''); raw.setup((r) => r.stat(TypeMoq.It.isAny())) // The parent dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); raw.setup((r) => r.copy(TypeMoq.It.isAny(), TypeMoq.It.isAny(), { overwrite: true })) // We don't care about the filename. .throws(new Error('file not found')); @@ -607,7 +607,7 @@ suite('Raw FileSystem', () => { test('wraps the low-level function', async () => { const dirname = 'x/y/z/spam'; raw.setup((r) => r.stat(Uri(dirname))) // The dir exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); raw.setup((r) => r.delete(Uri(dirname), opts)) // Expect the specific dirname. .returns(() => Promise.resolve()); @@ -618,7 +618,7 @@ suite('Raw FileSystem', () => { test('fails if the low-level call fails', async () => { raw.setup((r) => r.stat(TypeMoq.It.isAny())) // The "file" exists. - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); raw.setup((r) => r.delete(TypeMoq.It.isAny(), opts)) // We don't care about the filename. .throws(new Error('file not found')); @@ -1305,7 +1305,7 @@ suite('FileSystemUtils', () => { const dirname = 'x/y/z/spam'; const filename = `${dirname}/___vscpTest___`; deps.setup((d) => d.stat(dirname)) // Success! - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); deps.setup((d) => d.writeText(filename, '')) // Success! .returns(() => Promise.resolve()); deps.setup((d) => d.rmfile(filename)) // Success! @@ -1324,7 +1324,7 @@ suite('FileSystemUtils', () => { (err as any).code = 'EACCES'; // errno deps.setup((d) => d.stat(dirname)) // Success! - .returns(() => Promise.resolve(undefined as unknown as FileStat)); + .returns(() => Promise.resolve((undefined as unknown) as FileStat)); deps.setup((d) => d.writeText(filename, '')) // not permitted .returns(() => Promise.reject(err)); @@ -1435,7 +1435,7 @@ suite('FileSystemUtils', () => { test('no matches (undefined)', async () => { const pattern = `x/y/z/spam.*`; deps.setup((d) => d.globFile(pattern, undefined)) // found none - .returns(() => Promise.resolve(undefined as unknown as string[])); + .returns(() => Promise.resolve((undefined as unknown) as string[])); const files = await utils.search(pattern); @@ -1448,7 +1448,7 @@ suite('FileSystemUtils', () => { test('file exists', async () => { const filename = 'x/y/z/spam.py'; deps.setup((d) => d.statSync(filename)) // The file exists. - .returns(() => undefined as unknown as FileStat); + .returns(() => (undefined as unknown) as FileStat); const exists = utils.fileExistsSync(filename); diff --git a/extensions/positron-python/src/test/common/process/logger.unit.test.ts b/extensions/positron-python/src/test/common/process/logger.unit.test.ts index 342c4f7f054..ebce120b7e6 100644 --- a/extensions/positron-python/src/test/common/process/logger.unit.test.ts +++ b/extensions/positron-python/src/test/common/process/logger.unit.test.ts @@ -23,7 +23,7 @@ suite('ProcessLogger suite', () => { workspaceService = TypeMoq.Mock.ofType(); workspaceService .setup((w) => w.workspaceFolders) - .returns(() => [{ uri: { fsPath: path.join('path', 'to', 'workspace') } } as unknown as WorkspaceFolder]); + .returns(() => [({ uri: { fsPath: path.join('path', 'to', 'workspace') } } as unknown) as WorkspaceFolder]); logger = new ProcessLogger(workspaceService.object); }); diff --git a/extensions/positron-python/src/test/common/process/pythonExecutionFactory.unit.test.ts b/extensions/positron-python/src/test/common/process/pythonExecutionFactory.unit.test.ts index 5cf799c482c..e31a9e4d900 100644 --- a/extensions/positron-python/src/test/common/process/pythonExecutionFactory.unit.test.ts +++ b/extensions/positron-python/src/test/common/process/pythonExecutionFactory.unit.test.ts @@ -224,7 +224,7 @@ suite('Process - PythonExecutionFactory', () => { factory.create = async () => { createInvoked = true; // eslint-disable-next-line @typescript-eslint/no-explicit-any - return Promise.resolve(mockExecService as any as IPythonExecutionService); + return Promise.resolve((mockExecService as any) as IPythonExecutionService); }; const service = await verifyCreateActivated(factory, activationHelper, resource, interpreter); @@ -243,7 +243,7 @@ suite('Process - PythonExecutionFactory', () => { factory.create = async () => { createInvoked = true; // eslint-disable-next-line @typescript-eslint/no-explicit-any - return Promise.resolve(mockExecService as any as IPythonExecutionService); + return Promise.resolve((mockExecService as any) as IPythonExecutionService); }; const service = await verifyCreateActivated(factory, activationHelper, resource, interpreter); @@ -256,7 +256,7 @@ suite('Process - PythonExecutionFactory', () => { factory.create = async () => { createInvoked = true; // eslint-disable-next-line @typescript-eslint/no-explicit-any - return Promise.resolve(mockExecService as any as IPythonExecutionService); + return Promise.resolve((mockExecService as any) as IPythonExecutionService); }; const pythonSettings = mock(PythonSettings); @@ -345,7 +345,7 @@ suite('Process - PythonExecutionFactory', () => { factory.create = async () => { createInvoked = true; // eslint-disable-next-line @typescript-eslint/no-explicit-any - return Promise.resolve(mockExecService as any as IPythonExecutionService); + return Promise.resolve((mockExecService as any) as IPythonExecutionService); }; const pythonSettings = mock(PythonSettings); diff --git a/extensions/positron-python/src/test/common/socketStream.test.ts b/extensions/positron-python/src/test/common/socketStream.test.ts index 19298b132bf..35420e4a614 100644 --- a/extensions/positron-python/src/test/common/socketStream.test.ts +++ b/extensions/positron-python/src/test/common/socketStream.test.ts @@ -42,7 +42,7 @@ suite('SocketStream', () => { const byteValue = buffer[0]; const socket = new MockSocket(); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); assert.strictEqual(stream.ReadByte(), byteValue); done(); @@ -52,7 +52,7 @@ suite('SocketStream', () => { const socket = new MockSocket(); const buffer = uint64be.encode(num); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); assert.strictEqual(stream.ReadInt32(), num); done(); @@ -62,7 +62,7 @@ suite('SocketStream', () => { const socket = new MockSocket(); const buffer = uint64be.encode(num); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); assert.strictEqual(stream.ReadInt64(), num); done(); @@ -72,7 +72,7 @@ suite('SocketStream', () => { const socket = new MockSocket(); const buffer = Buffer.concat([Buffer.from('A'), uint64be.encode(message.length), Buffer.from(message)]); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); assert.strictEqual(stream.ReadString(), message); done(); @@ -86,7 +86,7 @@ suite('SocketStream', () => { stringBuffer, ]); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); assert.strictEqual(stream.ReadString(), message); done(); @@ -100,7 +100,7 @@ suite('SocketStream', () => { const partOfSecondMessage = Buffer.concat([Buffer.from('A'), uint64be.encode(message.length)]); buffer = Buffer.concat([buffer, partOfSecondMessage]); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); stream.BeginTransaction(); assert.strictEqual(stream.ReadString(), message, 'First message not read properly'); @@ -123,7 +123,7 @@ suite('SocketStream', () => { const partOfSecondMessage = Buffer.concat([Buffer.from('A'), uint64be.encode(message.length)]); buffer = Buffer.concat([buffer, partOfSecondMessage]); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); stream.BeginTransaction(); assert.strictEqual(stream.ReadString(), message, 'First message not read properly'); @@ -139,7 +139,7 @@ suite('SocketStream', () => { const buffer = Buffer.from(''); const socket = new MockSocket(); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); stream.Write(Buffer.from(message)); assert.strictEqual(socket.dataWritten, message); @@ -150,7 +150,7 @@ suite('SocketStream', () => { const buffer = Buffer.from(''); const socket = new MockSocket(); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); stream.WriteInt32(num); assert.strictEqual(uint64be.decode(socket.rawDataWritten), num); @@ -161,7 +161,7 @@ suite('SocketStream', () => { const buffer = Buffer.from(''); const socket = new MockSocket(); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); stream.WriteInt64(num); assert.strictEqual(uint64be.decode(socket.rawDataWritten), num); @@ -172,7 +172,7 @@ suite('SocketStream', () => { const buffer = Buffer.from(''); const socket = new MockSocket(); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); stream.WriteString(message); assert.strictEqual(socket.dataWritten, message); @@ -183,7 +183,7 @@ suite('SocketStream', () => { const buffer = Buffer.from(''); const socket = new MockSocket(); - const stream = new SocketStream(socket as any as net.Socket, buffer); + const stream = new SocketStream((socket as any) as net.Socket, buffer); stream.WriteString(message); assert.strictEqual(socket.dataWritten, message); diff --git a/extensions/positron-python/src/test/common/terminals/activation.bash.unit.test.ts b/extensions/positron-python/src/test/common/terminals/activation.bash.unit.test.ts index 035ed5a4ab3..cd057e7be3e 100644 --- a/extensions/positron-python/src/test/common/terminals/activation.bash.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/activation.bash.unit.test.ts @@ -45,7 +45,7 @@ suite('Terminal Environment Activation (bash)', () => { interpreterService = TypeMoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); serviceContainer .setup((c) => c.get(IInterpreterService)) .returns(() => interpreterService.object); diff --git a/extensions/positron-python/src/test/common/terminals/activation.commandPrompt.unit.test.ts b/extensions/positron-python/src/test/common/terminals/activation.commandPrompt.unit.test.ts index 2cedbd06e1a..ed21d7625da 100644 --- a/extensions/positron-python/src/test/common/terminals/activation.commandPrompt.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/activation.commandPrompt.unit.test.ts @@ -39,7 +39,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { interpreterService = TypeMoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); serviceContainer .setup((c) => c.get(IInterpreterService)) .returns(() => interpreterService.object); @@ -89,7 +89,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { interpreterService = TypeMoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); serviceContainer.setup((c) => c.get(IInterpreterService)).returns(() => interpreterService.object); serviceContainer.setup((c) => c.get(IFileSystem)).returns(() => fileSystem.object); serviceContainer.setup((c) => c.get(IPlatformService)).returns(() => platform.object); @@ -181,7 +181,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { interpreterService = TypeMoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); serviceContainer.setup((c) => c.get(IInterpreterService)).returns(() => interpreterService.object); }); diff --git a/extensions/positron-python/src/test/common/terminals/activation.nushell.unit.test.ts b/extensions/positron-python/src/test/common/terminals/activation.nushell.unit.test.ts index b146cedfa02..bf748bc7c05 100644 --- a/extensions/positron-python/src/test/common/terminals/activation.nushell.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/activation.nushell.unit.test.ts @@ -29,7 +29,7 @@ suite('Terminal Environment Activation (nushell)', () => { interpreterService = TypeMoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); serviceContainer.setup((c) => c.get(IInterpreterService)).returns(() => interpreterService.object); }); diff --git a/extensions/positron-python/src/test/common/terminals/activation.unit.test.ts b/extensions/positron-python/src/test/common/terminals/activation.unit.test.ts index 65e6dd67b47..49ada1c06b1 100644 --- a/extensions/positron-python/src/test/common/terminals/activation.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/activation.unit.test.ts @@ -25,7 +25,7 @@ suite('Terminal Auto Activation', () => { let terminal: Terminal; setup(() => { - terminal = { + terminal = ({ dispose: noop, hide: noop, name: 'Python', @@ -34,7 +34,7 @@ suite('Terminal Auto Activation', () => { sendText: noop, show: noop, exitStatus: { code: 0 }, - } as unknown as Terminal; + } as unknown) as Terminal; terminalManager = mock(TerminalManager); activator = mock(TerminalActivator); activeResourceService = mock(ActiveResourceService); @@ -68,7 +68,7 @@ suite('Terminal Auto Activation', () => { verify(activator.activateEnvironmentInTerminal(terminal, anything())).once(); }); test('New Terminals should not be activated if hidden from user', async () => { - terminal = { + terminal = ({ dispose: noop, hide: noop, name: 'Python', @@ -77,7 +77,7 @@ suite('Terminal Auto Activation', () => { sendText: noop, show: noop, exitStatus: { code: 0 }, - } as unknown as Terminal; + } as unknown) as Terminal; type EventHandler = (e: Terminal) => void; let handler: undefined | EventHandler; const handlerDisposable = TypeMoq.Mock.ofType(); @@ -98,7 +98,7 @@ suite('Terminal Auto Activation', () => { verify(activator.activateEnvironmentInTerminal(terminal, anything())).never(); }); test('New Terminals should not be activated if auto activation is to be disabled', async () => { - terminal = { + terminal = ({ dispose: noop, hide: noop, name: 'Python', @@ -107,7 +107,7 @@ suite('Terminal Auto Activation', () => { sendText: noop, show: noop, exitStatus: { code: 0 }, - } as unknown as Terminal; + } as unknown) as Terminal; type EventHandler = (e: Terminal) => void; let handler: undefined | EventHandler; const handlerDisposable = TypeMoq.Mock.ofType(); diff --git a/extensions/positron-python/src/test/common/terminals/activator/base.unit.test.ts b/extensions/positron-python/src/test/common/terminals/activator/base.unit.test.ts index 4acb7d6ad42..fdfe9dcee57 100644 --- a/extensions/positron-python/src/test/common/terminals/activator/base.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/activator/base.unit.test.ts @@ -16,12 +16,12 @@ suite('Terminal Base Activator', () => { setup(() => { helper = TypeMoq.Mock.ofType(); - activator = new (class extends BaseTerminalActivator { + activator = (new (class extends BaseTerminalActivator { public waitForCommandToProcess() { noop(); return Promise.resolve(); } - })(helper.object) as any as ITerminalActivator; + })(helper.object) as any) as ITerminalActivator; }); [ { commandCount: 1, preserveFocus: false }, diff --git a/extensions/positron-python/src/test/common/terminals/activator/index.unit.test.ts b/extensions/positron-python/src/test/common/terminals/activator/index.unit.test.ts index 23ff745d7b8..e916af8d682 100644 --- a/extensions/positron-python/src/test/common/terminals/activator/index.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/activator/index.unit.test.ts @@ -37,9 +37,9 @@ suite('Terminal Activator', () => { configService .setup((c) => c.getSettings(TypeMoq.It.isAny())) .returns(() => { - return { + return ({ terminal: terminalSettings.object, - } as unknown as IPythonSettings; + } as unknown) as IPythonSettings; }); activator = new (class extends TerminalActivator { protected initialize() { diff --git a/extensions/positron-python/src/test/common/terminals/helper.unit.test.ts b/extensions/positron-python/src/test/common/terminals/helper.unit.test.ts index 6e2aa579066..b6a8d44ac03 100644 --- a/extensions/positron-python/src/test/common/terminals/helper.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/helper.unit.test.ts @@ -222,7 +222,7 @@ suite('Terminal Service helpers', () => { when(pipenvActivationProvider.isShellSupported(anything())).thenReturn(false); const cmd = await helper.getEnvironmentActivationCommands( - 'someShell' as any as TerminalShellType, + ('someShell' as any) as TerminalShellType, resource, ); diff --git a/extensions/positron-python/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts b/extensions/positron-python/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts index c53820f1713..e58e455ea7e 100644 --- a/extensions/positron-python/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts +++ b/extensions/positron-python/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts @@ -103,9 +103,9 @@ suite('Shell Detectors', () => { shellPathsAndIdentification.forEach((shellType, shellPath) => { when(appEnv.shell).thenReturn('defaultshellPath'); expect( - shellDetector.identify(telemetryProperties, { + shellDetector.identify(telemetryProperties, ({ creationOptions: { shellPath }, - } as unknown as Terminal), + } as unknown) as Terminal), ).to.equal(shellType, `Incorrect Shell Type from identifyShellByTerminalName, for path '${shellPath}'`); }); }); diff --git a/extensions/positron-python/src/test/common/utils/version.unit.test.ts b/extensions/positron-python/src/test/common/utils/version.unit.test.ts index 30cd8b57d9f..3541b9b8292 100644 --- a/extensions/positron-python/src/test/common/utils/version.unit.test.ts +++ b/extensions/positron-python/src/test/common/utils/version.unit.test.ts @@ -35,13 +35,13 @@ function ver( micro = -1; } const info = { - major: major as unknown as number, - minor: minor as unknown as number, - micro: micro as unknown as number, + major: (major as unknown) as number, + minor: (minor as unknown) as number, + micro: (micro as unknown) as number, raw: undefined, }; if (unnormalized !== undefined) { - (info as unknown as any).unnormalized = unnormalized; + ((info as unknown) as any).unnormalized = unnormalized; } return info; } @@ -143,7 +143,7 @@ suite('common utils - normalizeVersionInfo', () => { const info = ver(1, 2, 3); info.raw = '1.2.3'; - (info as unknown as any).unnormalized = unnorm('', '', ''); + ((info as unknown) as any).unnormalized = unnorm('', '', ''); const expected = info; const normalized = normalizeVersionInfo(info); @@ -188,7 +188,7 @@ suite('common utils - normalizeVersionInfo', () => { ].forEach((data) => { const [info, expected] = data; - (expected as unknown as any).unnormalized = unnorm('', '', ''); + ((expected as unknown) as any).unnormalized = unnorm('', '', ''); expected.raw = ''; test(`[${info.major}, ${info.minor}, ${info.micro}]`, () => { const normalized = normalizeVersionInfo(info); @@ -199,18 +199,16 @@ suite('common utils - normalizeVersionInfo', () => { }); suite('partially "invalid"', () => { - ( - [ - [ver(undefined, 4, 5), unnorm('missing', '', '')], - [ver(3, null, 5), unnorm('', 'missing', '')], - [ver(3, 4, NaN), unnorm('', '', 'missing')], - [ver(3, 4, ''), unnorm('', '', 'string not numeric')], - [ver(3, 4, ' '), unnorm('', '', 'string not numeric')], - [ver(3, 4, 'foo'), unnorm('', '', 'string not numeric')], - [ver(3, 4, {}), unnorm('', '', 'unsupported type')], - [ver(3, 4, []), unnorm('', '', 'unsupported type')], - ] as [VersionInfo, Unnormalized][] - ).forEach((data) => { + ([ + [ver(undefined, 4, 5), unnorm('missing', '', '')], + [ver(3, null, 5), unnorm('', 'missing', '')], + [ver(3, 4, NaN), unnorm('', '', 'missing')], + [ver(3, 4, ''), unnorm('', '', 'string not numeric')], + [ver(3, 4, ' '), unnorm('', '', 'string not numeric')], + [ver(3, 4, 'foo'), unnorm('', '', 'string not numeric')], + [ver(3, 4, {}), unnorm('', '', 'unsupported type')], + [ver(3, 4, []), unnorm('', '', 'unsupported type')], + ] as [VersionInfo, Unnormalized][]).forEach((data) => { const [info, unnormalized] = data; const expected = { ...info }; if (info.major !== 3) { @@ -221,7 +219,7 @@ suite('common utils - normalizeVersionInfo', () => { expected.micro = -1; } - (expected as unknown as any).unnormalized = unnormalized; + ((expected as unknown) as any).unnormalized = unnormalized; expected.raw = ''; test(`[${info.major}, ${info.minor}, ${info.micro}]`, () => { const normalized = normalizeVersionInfo(info); @@ -312,30 +310,28 @@ suite('common utils - parseVersionInfo', () => { }); suite('valid versions', () => { - ( + ([ + // plain + ...VERSIONS.map(([v, s]) => [s, { version: v, before: '', after: '' }]), + ['02.7', res(2, 7, -1, '', '')], + ['2.07', res(2, 7, -1, '', '')], + ['2.7.01', res(2, 7, 1, '', '')], + // with before/after + [' 2.7.9 ', res(2, 7, 9, ' ', ' ')], + ['2.7.9-3.2.7', res(2, 7, 9, '', '-3.2.7')], + ['python2.7.exe', res(2, 7, -1, 'python', '.exe')], + ['1.2.3.4.5-x2.2', res(1, 2, 3, '', '.4.5-x2.2')], + ['3.8.1a2', res(3, 8, 1, '', 'a2')], + ['3.8.1-alpha2', res(3, 8, 1, '', '-alpha2')], [ - // plain - ...VERSIONS.map(([v, s]) => [s, { version: v, before: '', after: '' }]), - ['02.7', res(2, 7, -1, '', '')], - ['2.07', res(2, 7, -1, '', '')], - ['2.7.01', res(2, 7, 1, '', '')], - // with before/after - [' 2.7.9 ', res(2, 7, 9, ' ', ' ')], - ['2.7.9-3.2.7', res(2, 7, 9, '', '-3.2.7')], - ['python2.7.exe', res(2, 7, -1, 'python', '.exe')], - ['1.2.3.4.5-x2.2', res(1, 2, 3, '', '.4.5-x2.2')], - ['3.8.1a2', res(3, 8, 1, '', 'a2')], - ['3.8.1-alpha2', res(3, 8, 1, '', '-alpha2')], - [ - '3.7.5 (default, Nov 7 2019, 10:50:52) \\n[GCC 8.3.0]', - res(3, 7, 5, '', ' (default, Nov 7 2019, 10:50:52) \\n[GCC 8.3.0]'), - ], - ['python2', res(2, -1, -1, 'python', '')], - // without the "before" the following won't match. - ['python2.a', res(2, -1, -1, 'python', '.a')], - ['python2.b7', res(2, -1, -1, 'python', '.b7')], - ] as [string, ParseResult][] - ).forEach((data) => { + '3.7.5 (default, Nov 7 2019, 10:50:52) \\n[GCC 8.3.0]', + res(3, 7, 5, '', ' (default, Nov 7 2019, 10:50:52) \\n[GCC 8.3.0]'), + ], + ['python2', res(2, -1, -1, 'python', '')], + // without the "before" the following won't match. + ['python2.a', res(2, -1, -1, 'python', '.a')], + ['python2.b7', res(2, -1, -1, 'python', '.b7')], + ] as [string, ParseResult][]).forEach((data) => { const [verStr, result] = data; if (verStr === '') { return; diff --git a/extensions/positron-python/src/test/common/variables/envVarsService.unit.test.ts b/extensions/positron-python/src/test/common/variables/envVarsService.unit.test.ts index 73b97c67bac..0c978b2f9e8 100644 --- a/extensions/positron-python/src/test/common/variables/envVarsService.unit.test.ts +++ b/extensions/positron-python/src/test/common/variables/envVarsService.unit.test.ts @@ -554,12 +554,10 @@ VAR2_B="${VAR1}\\n"def \n\ }); test('Curly braces are required for substitution', () => { - const vars = parseEnvFile( - '\ + const vars = parseEnvFile('\ SPAM=1234 \n\ EGGS=$SPAM \n\ - ', - ); + '); expect(vars).to.not.equal(undefined, 'Variables is undefiend'); expect(Object.keys(vars!)).lengthOf(2, 'Incorrect number of variables'); @@ -651,14 +649,11 @@ FOO=foo\\$bar \n\ }); test('base substitution variables', () => { - const vars = parseEnvFile( - '\ + const vars = parseEnvFile('\ PYTHONPATH=${REPO}/foo:${REPO}/bar \n\ - ', - { - REPO: '/home/user/git/foobar', - }, - ); + ', { + REPO: '/home/user/git/foobar', + }); expect(vars).to.not.equal(undefined, 'Variables is undefiend'); expect(Object.keys(vars!)).lengthOf(1, 'Incorrect number of variables'); diff --git a/extensions/positron-python/src/test/configuration/environmentTypeComparer.unit.test.ts b/extensions/positron-python/src/test/configuration/environmentTypeComparer.unit.test.ts index 60b5359a174..53f6bccad3c 100644 --- a/extensions/positron-python/src/test/configuration/environmentTypeComparer.unit.test.ts +++ b/extensions/positron-python/src/test/configuration/environmentTypeComparer.unit.test.ts @@ -35,10 +35,10 @@ suite('Environment sorting', () => { getActiveWorkspaceUriStub = sinon.stub().returns({ folderUri: { fsPath: workspacePath } }); getInterpreterTypeDisplayNameStub = sinon.stub(); - interpreterHelper = { + interpreterHelper = ({ getActiveWorkspaceUri: getActiveWorkspaceUriStub, getInterpreterTypeDisplayName: getInterpreterTypeDisplayNameStub, - } as unknown as IInterpreterHelper; + } as unknown) as IInterpreterHelper; const getActivePyenvForDirectory = sinon.stub(pyenv, 'getActivePyenvForDirectory'); getActivePyenvForDirectory.resolves(preferredPyenv); }); @@ -231,7 +231,8 @@ suite('Environment sorting', () => { expected: 1, }, { - title: 'Microsoft Store interpreter should not come first when there are global interpreters with higher version', + title: + 'Microsoft Store interpreter should not come first when there are global interpreters with higher version', envA: { envType: EnvironmentType.MicrosoftStore, version: { major: 3, minor: 10, patch: 2, raw: '3.10.2' }, @@ -273,7 +274,8 @@ suite('Environment sorting', () => { expected: 1, }, { - title: "If 2 global environments have the same Python version and there's a Conda one, the Conda env should not come first", + title: + "If 2 global environments have the same Python version and there's a Conda one, the Conda env should not come first", envA: { envType: EnvironmentType.Conda, type: PythonEnvType.Conda, @@ -289,7 +291,8 @@ suite('Environment sorting', () => { expected: 1, }, { - title: 'If 2 global environments are of the same type and have the same Python version, they should be sorted by name', + title: + 'If 2 global environments are of the same type and have the same Python version, they should be sorted by name', envA: { envType: EnvironmentType.Conda, type: PythonEnvType.Conda, @@ -364,14 +367,14 @@ suite('getPyenvVersion tests', () => { getActiveWorkspaceNoWorkspaceUriStub = sinon.stub().returns(undefined); getInterpreterTypeDisplayNameStub = sinon.stub(); - interpreterHelper = { + interpreterHelper = ({ getActiveWorkspaceUri: getActiveWorkspaceUriStub, getInterpreterTypeDisplayName: getInterpreterTypeDisplayNameStub, - } as unknown as IInterpreterHelper; - interpreterHelperNoWorkspace = { + } as unknown) as IInterpreterHelper; + interpreterHelperNoWorkspace = ({ getActiveWorkspaceUri: getActiveWorkspaceNoWorkspaceUriStub, getInterpreterTypeDisplayName: getInterpreterTypeDisplayNameStub, - } as unknown as IInterpreterHelper; + } as unknown) as IInterpreterHelper; pathExistsSyncStub = sinon.stub(externalDependencies, 'pathExistsSync'); pathExistsSyncStub.withArgs('').returns(false); diff --git a/extensions/positron-python/src/test/configuration/interpreterSelector/commands/resetInterpreter.unit.test.ts b/extensions/positron-python/src/test/configuration/interpreterSelector/commands/resetInterpreter.unit.test.ts index db84ce76a50..e1c3a960b99 100644 --- a/extensions/positron-python/src/test/configuration/interpreterSelector/commands/resetInterpreter.unit.test.ts +++ b/extensions/positron-python/src/test/configuration/interpreterSelector/commands/resetInterpreter.unit.test.ts @@ -27,7 +27,7 @@ suite('Reset Interpreter Command', () => { configurationService .setup((c) => c.getSettings(TypeMoq.It.isAny())) // eslint-disable-next-line @typescript-eslint/no-explicit-any - .returns(() => ({ pythonPath: 'pythonPath' }) as any); + .returns(() => ({ pythonPath: 'pythonPath' } as any)); commandManager = TypeMoq.Mock.ofType(); appShell = TypeMoq.Mock.ofType(); pythonPathUpdater = TypeMoq.Mock.ofType(); diff --git a/extensions/positron-python/src/test/configuration/interpreterSelector/commands/setInterpreter.unit.test.ts b/extensions/positron-python/src/test/configuration/interpreterSelector/commands/setInterpreter.unit.test.ts index 69648997285..6c71dd7d6ec 100644 --- a/extensions/positron-python/src/test/configuration/interpreterSelector/commands/setInterpreter.unit.test.ts +++ b/extensions/positron-python/src/test/configuration/interpreterSelector/commands/setInterpreter.unit.test.ts @@ -200,7 +200,7 @@ suite('Set Interpreter Command', () => { workspace .setup((w) => w.getWorkspaceFolder(TypeMoq.It.isAny())) - .returns(() => ({ uri: { fsPath: workspacePath } }) as unknown as WorkspaceFolder); + .returns(() => (({ uri: { fsPath: workspacePath } } as unknown) as WorkspaceFolder)); setInterpreterCommand = new SetInterpreterCommand( appShell.object, @@ -261,7 +261,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); await setInterpreterCommand._pickInterpreter(multiStepInput.object, state); @@ -272,9 +272,9 @@ suite('Set Interpreter Command', () => { delete actualParameters!.customButtonSetups; delete actualParameters!.onChangeItem; if (typeof actualParameters!.activeItem === 'function') { - const activeItem = await actualParameters!.activeItem({ + const activeItem = await actualParameters!.activeItem(({ items: suggestions, - } as unknown as QuickPick); + } as unknown) as QuickPick); assert.deepStrictEqual(activeItem, recommended); } else { assert(false, 'Not a function'); @@ -313,7 +313,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); await setInterpreterCommand._pickInterpreter(multiStepInput.object, state, undefined, { showCreateEnvironment: true, @@ -326,9 +326,9 @@ suite('Set Interpreter Command', () => { delete actualParameters!.customButtonSetups; delete actualParameters!.onChangeItem; if (typeof actualParameters!.activeItem === 'function') { - const activeItem = await actualParameters!.activeItem({ + const activeItem = await actualParameters!.activeItem(({ items: suggestions, - } as unknown as QuickPick); + } as unknown) as QuickPick); assert.deepStrictEqual(activeItem, recommended); } else { assert(false, 'Not a function'); @@ -361,7 +361,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); interpreterSelector.reset(); interpreterSelector .setup((i) => i.getSuggestions(TypeMoq.It.isAny(), TypeMoq.It.isAny())) @@ -376,9 +376,9 @@ suite('Set Interpreter Command', () => { delete actualParameters!.customButtonSetups; delete actualParameters!.onChangeItem; if (typeof actualParameters!.activeItem === 'function') { - const activeItem = await actualParameters!.activeItem({ + const activeItem = await actualParameters!.activeItem(({ items: suggestions, - } as unknown as QuickPick); + } as unknown) as QuickPick); assert.deepStrictEqual(activeItem, noPythonInstalled); } else { assert(false, 'Not a function'); @@ -392,7 +392,7 @@ suite('Set Interpreter Command', () => { const multiStepInput = TypeMoq.Mock.ofType>(); multiStepInput .setup((i) => i.showQuickPick(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(noPythonInstalled as unknown as QuickPickItem)); + .returns(() => Promise.resolve((noPythonInstalled as unknown) as QuickPickItem)); interpreterSelector.reset(); interpreterSelector .setup((i) => i.getSuggestions(TypeMoq.It.isAny(), TypeMoq.It.isAny())) @@ -412,7 +412,7 @@ suite('Set Interpreter Command', () => { const multiStepInput = TypeMoq.Mock.ofType>(); multiStepInput .setup((i) => i.showQuickPick(TypeMoq.It.isAny())) - .returns(() => Promise.resolve(tipToReloadWindow as unknown as QuickPickItem)); + .returns(() => Promise.resolve((tipToReloadWindow as unknown) as QuickPickItem)); interpreterSelector.reset(); interpreterSelector .setup((i) => i.getSuggestions(TypeMoq.It.isAny(), TypeMoq.It.isAny())) @@ -531,7 +531,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); await setInterpreterCommand._pickInterpreter(multiStepInput.object, state); @@ -643,7 +643,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); await setInterpreterCommand._pickInterpreter( multiStepInput.object, @@ -736,7 +736,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); await setInterpreterCommand._pickInterpreter(multiStepInput.object, state); @@ -748,9 +748,9 @@ suite('Set Interpreter Command', () => { delete actualParameters!.customButtonSetups; delete actualParameters!.onChangeItem; if (typeof actualParameters!.activeItem === 'function') { - const activeItem = await actualParameters!.activeItem({ + const activeItem = await actualParameters!.activeItem(({ items: suggestions, - } as unknown as QuickPick); + } as unknown) as QuickPick); assert.deepStrictEqual(activeItem, recommended); } else { assert(false, 'Not a function'); @@ -769,7 +769,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); await setInterpreterCommand._pickInterpreter(multiStepInput.object, state); @@ -792,7 +792,7 @@ suite('Set Interpreter Command', () => { .callback((options) => { actualParameters = options; }) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)); + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)); const refreshPromiseDeferred = createDeferred(); // Assume a refresh is currently going on... when(interpreterService.refreshPromise).thenReturn(refreshPromiseDeferred.promise); @@ -818,7 +818,7 @@ suite('Set Interpreter Command', () => { old: item.interpreter, new: refreshedItem.interpreter, }; - await onChangedCallback!(changeEvent, quickPick as unknown as QuickPick); // Invoke callback, meaning that the items are supposed to change. + await onChangedCallback!(changeEvent, (quickPick as unknown) as QuickPick); // Invoke callback, meaning that the items are supposed to change. assert.deepStrictEqual( quickPick, @@ -903,7 +903,7 @@ suite('Set Interpreter Command', () => { interpreterSelector .setup((i) => i.suggestionToQuickPickItem(TypeMoq.It.isValue(newItem.interpreter), undefined, false)) .returns(() => newItem); - await onChangedCallback!(changeEvent2, quickPick as unknown as QuickPick); // Invoke callback, meaning that the items are supposed to change. + await onChangedCallback!(changeEvent2, (quickPick as unknown) as QuickPick); // Invoke callback, meaning that the items are supposed to change. assert.deepStrictEqual( quickPick, @@ -1004,7 +1004,7 @@ suite('Set Interpreter Command', () => { const multiStepInput = TypeMoq.Mock.ofType>(); multiStepInput .setup((i) => i.showQuickPick(expectedParameters)) - .returns(() => Promise.resolve(undefined as unknown as QuickPickItem)) + .returns(() => Promise.resolve((undefined as unknown) as QuickPickItem)) .verifiable(TypeMoq.Times.once()); await setInterpreterCommand._enterOrBrowseInterpreterPath(multiStepInput.object, state); diff --git a/extensions/positron-python/src/test/configuration/interpreterSelector/interpreterSelector.unit.test.ts b/extensions/positron-python/src/test/configuration/interpreterSelector/interpreterSelector.unit.test.ts index 600aad5948c..2ec20be6699 100644 --- a/extensions/positron-python/src/test/configuration/interpreterSelector/interpreterSelector.unit.test.ts +++ b/extensions/positron-python/src/test/configuration/interpreterSelector/interpreterSelector.unit.test.ts @@ -39,7 +39,7 @@ class InterpreterQuickPickItem implements IInterpreterQuickPickItem { public detail?: string; - public interpreter = {} as unknown as PythonEnvironment; + public interpreter = ({} as unknown) as PythonEnvironment; constructor(l: string, p: string, d?: string) { this.path = p; @@ -172,7 +172,7 @@ suite('Interpreters - selector', () => { const interpreterHelper = TypeMoq.Mock.ofType(); interpreterHelper .setup((i) => i.getActiveWorkspaceUri(TypeMoq.It.isAny())) - .returns(() => ({ folderUri: { fsPath: workspacePath } }) as WorkspacePythonPath); + .returns(() => ({ folderUri: { fsPath: workspacePath } } as WorkspacePythonPath)); const environmentTypeComparer = new EnvironmentTypeComparer(interpreterHelper.object); diff --git a/extensions/positron-python/src/test/debugger/envVars.test.ts b/extensions/positron-python/src/test/debugger/envVars.test.ts index 7eddeeadb22..c043146fe53 100644 --- a/extensions/positron-python/src/test/debugger/envVars.test.ts +++ b/extensions/positron-python/src/test/debugger/envVars.test.ts @@ -56,13 +56,13 @@ suite('Resolving Environment Variables when Debugging', () => { } async function testBasicProperties(console: ConsoleType, expectedNumberOfVariables: number) { - const args = { + const args = ({ program: '', pythonPath: '', args: [], envFile: '', console, - } as any as LaunchRequestArguments; + } as any) as LaunchRequestArguments; const envVars = await debugEnvParser.getEnvironmentVariables(args); expect(envVars).not.be.undefined; @@ -79,14 +79,14 @@ suite('Resolving Environment Variables when Debugging', () => { test('Confirm base environment variables are merged without overwriting when provided', async () => { const env: Record = { DO_NOT_OVERWRITE: '1' }; - const args = { + const args = ({ program: '', pythonPath: '', args: [], envFile: '', console, env, - } as any as LaunchRequestArguments; + } as any) as LaunchRequestArguments; const baseEnvVars = { CONDA_PREFIX: 'path/to/conda/env', DO_NOT_OVERWRITE: '0' }; const envVars = await debugEnvParser.getEnvironmentVariables(args, baseEnvVars); @@ -118,14 +118,14 @@ suite('Resolving Environment Variables when Debugging', () => { env[prop2] = prop2; mockProcess.env[prop3] = prop3; - const args = { + const args = ({ program: '', pythonPath: '', args: [], envFile: '', console, env, - } as any as LaunchRequestArguments; + } as any) as LaunchRequestArguments; const envVars = await debugEnvParser.getEnvironmentVariables(args); @@ -183,14 +183,14 @@ suite('Resolving Environment Variables when Debugging', () => { env[prop2] = prop2; mockProcess.env[prop3] = prop3; - const args = { + const args = ({ program: '', pythonPath: '', args: [], envFile: '', console, env, - } as any as LaunchRequestArguments; + } as any) as LaunchRequestArguments; const envVars = await debugEnvParser.getEnvironmentVariables(args); expect(envVars).not.be.undefined; diff --git a/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts index 11683afd69e..6204bb83547 100644 --- a/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/adapter/factory.unit.test.ts @@ -87,9 +87,9 @@ suite('Debugging - Adapter Factory', () => { ).thenReturn(instance(state)); const configurationService = mock(ConfigurationService); - when(configurationService.getSettings(undefined)).thenReturn({ + when(configurationService.getSettings(undefined)).thenReturn(({ experiments: { enabled: true }, - } as any as IPythonSettings); + } as any) as IPythonSettings); interpreterService = mock(InterpreterService); diff --git a/extensions/positron-python/src/test/debugger/extension/adapter/outdatedDebuggerPrompt.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/adapter/outdatedDebuggerPrompt.unit.test.ts index 04326835a64..0ab094119a5 100644 --- a/extensions/positron-python/src/test/debugger/extension/adapter/outdatedDebuggerPrompt.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/adapter/outdatedDebuggerPrompt.unit.test.ts @@ -38,9 +38,9 @@ suite('Debugging - Outdated Debugger Prompt tests.', () => { setup(() => { const configurationService = mock(ConfigurationService); - when(configurationService.getSettings(undefined)).thenReturn({ + when(configurationService.getSettings(undefined)).thenReturn(({ experiments: { enabled: true }, - } as any as IPythonSettings); + } as any) as IPythonSettings); showInformationMessageStub = sinon.stub(windowApis, 'showInformationMessage'); browserLaunchStub = sinon.stub(browserApis, 'launch'); diff --git a/extensions/positron-python/src/test/debugger/extension/attachQuickPick/provider.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/attachQuickPick/provider.unit.test.ts index fdeda6af60f..64d9103f3c5 100644 --- a/extensions/positron-python/src/test/debugger/extension/attachQuickPick/provider.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/attachQuickPick/provider.unit.test.ts @@ -397,7 +397,8 @@ ProcessId=8026\r { label: 'python.exe', description: '8026', - detail: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/foo_bar.py', + detail: + 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/foo_bar.py', id: '8026', processName: 'python.exe', commandLine: @@ -406,7 +407,8 @@ ProcessId=8026\r { label: 'python.exe', description: '6028', - detail: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', + detail: + 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', id: '6028', processName: 'python.exe', commandLine: diff --git a/extensions/positron-python/src/test/debugger/extension/attachQuickPick/wmicProcessParser.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/attachQuickPick/wmicProcessParser.unit.test.ts index ba36cfdf61e..e29490c4792 100644 --- a/extensions/positron-python/src/test/debugger/extension/attachQuickPick/wmicProcessParser.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/attachQuickPick/wmicProcessParser.unit.test.ts @@ -70,7 +70,8 @@ ProcessId=6028\r\n\ { label: 'python.exe', description: '6028', - detail: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', + detail: + 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', id: '6028', processName: 'python.exe', commandLine: @@ -147,7 +148,8 @@ ProcessId=6028\r\n\ { label: 'python.exe', description: '6028', - detail: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', + detail: + 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', id: '6028', processName: 'python.exe', commandLine: @@ -197,7 +199,8 @@ ProcessId=6028\r\n\ { label: 'python.exe', description: '6028', - detail: 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', + detail: + 'C:\\Users\\Contoso\\AppData\\Local\\Programs\\Python\\Python37\\python.exe c:/Users/Contoso/Documents/hello_world.py', id: '6028', processName: 'python.exe', commandLine: diff --git a/extensions/positron-python/src/test/debugger/extension/configuration/debugConfigurationService.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/configuration/debugConfigurationService.unit.test.ts index 5477f7e6ead..ae13ad37537 100644 --- a/extensions/positron-python/src/test/debugger/extension/configuration/debugConfigurationService.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/configuration/debugConfigurationService.unit.test.ts @@ -22,9 +22,9 @@ suite('Debugging - Configuration Service', () => { configService = new TestPythonDebugConfigurationService(attachResolver.object, launchResolver.object); }); test('Should use attach resolver when passing attach config', async () => { - const config = { + const config = ({ request: 'attach', - } as DebugConfiguration as AttachRequestArguments; + } as DebugConfiguration) as AttachRequestArguments; const folder = { name: '1', index: 0, uri: Uri.parse('1234') }; const expectedConfig = { yay: 1 }; @@ -32,7 +32,7 @@ suite('Debugging - Configuration Service', () => { .setup((a) => a.resolveDebugConfiguration(typemoq.It.isValue(folder), typemoq.It.isValue(config), typemoq.It.isAny()), ) - .returns(() => Promise.resolve(expectedConfig as unknown as AttachRequestArguments)) + .returns(() => Promise.resolve((expectedConfig as unknown) as AttachRequestArguments)) .verifiable(typemoq.Times.once()); launchResolver .setup((a) => a.resolveDebugConfiguration(typemoq.It.isAny(), typemoq.It.isAny(), typemoq.It.isAny())) @@ -53,11 +53,11 @@ suite('Debugging - Configuration Service', () => { .setup((a) => a.resolveDebugConfiguration( typemoq.It.isValue(folder), - typemoq.It.isValue(config as DebugConfiguration as LaunchRequestArguments), + typemoq.It.isValue((config as DebugConfiguration) as LaunchRequestArguments), typemoq.It.isAny(), ), ) - .returns(() => Promise.resolve(expectedConfig as unknown as LaunchRequestArguments)) + .returns(() => Promise.resolve((expectedConfig as unknown) as LaunchRequestArguments)) .verifiable(typemoq.Times.once()); attachResolver .setup((a) => a.resolveDebugConfiguration(typemoq.It.isAny(), typemoq.It.isAny(), typemoq.It.isAny())) diff --git a/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/base.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/base.unit.test.ts index df700fb28cc..4da645bc34a 100644 --- a/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/base.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/base.unit.test.ts @@ -156,7 +156,7 @@ suite('Debugging - Config Resolver', () => { expect(uri).to.be.deep.equal(undefined, 'not undefined'); }); test('Do nothing if debug configuration is undefined', async () => { - await resolver.resolveAndUpdatePythonPath(undefined, undefined as unknown as LaunchRequestArguments); + await resolver.resolveAndUpdatePythonPath(undefined, (undefined as unknown) as LaunchRequestArguments); }); test('python in debug config must point to pythonPath in settings if pythonPath in config is not set', async () => { const config = {}; diff --git a/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts index ad63f561859..59f61f81cd8 100644 --- a/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts @@ -149,9 +149,8 @@ getInfoPerOS().forEach(([osName, osType, path]) => { return config; } - const interpreterPath = configService.object.getSettings( - workspaceFolder ? workspaceFolder.uri : undefined, - ).pythonPath; + const interpreterPath = configService.object.getSettings(workspaceFolder ? workspaceFolder.uri : undefined) + .pythonPath; for (const key of Object.keys(config)) { const value = config[key]; if (typeof value === 'string') { diff --git a/extensions/positron-python/src/test/debugger/extension/debugCommands.unit.test.ts b/extensions/positron-python/src/test/debugger/extension/debugCommands.unit.test.ts index 04a9c3f6e44..7d2463072f0 100644 --- a/extensions/positron-python/src/test/debugger/extension/debugCommands.unit.test.ts +++ b/extensions/positron-python/src/test/debugger/extension/debugCommands.unit.test.ts @@ -34,7 +34,7 @@ suite('Debugging - commands', () => { interpreterService = typemoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(typemoq.It.isAny())) - .returns(() => Promise.resolve({ path: 'ps' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: 'ps' } as unknown) as PythonEnvironment)); sinon.stub(telemetry, 'sendTelemetryEvent').callsFake(() => { /** noop */ }); diff --git a/extensions/positron-python/src/test/debugger/utils.ts b/extensions/positron-python/src/test/debugger/utils.ts index b479eee5c9f..749adb35959 100644 --- a/extensions/positron-python/src/test/debugger/utils.ts +++ b/extensions/positron-python/src/test/debugger/utils.ts @@ -80,9 +80,9 @@ class DebugAdapterTracker { this.tracked.dapHandler(src, msg); } if (msg.type === 'event') { - const event = (msg as unknown as DebugProtocol.Event).event; + const event = ((msg as unknown) as DebugProtocol.Event).event; if (event === 'output') { - this.onOutputEvent(msg as unknown as DebugProtocol.OutputEvent); + this.onOutputEvent((msg as unknown) as DebugProtocol.OutputEvent); } } } @@ -233,12 +233,12 @@ class DebuggerSession { public handleDAPMessage(_src: DAPSource, baseMsg: DebugProtocol.ProtocolMessage) { if (baseMsg.type === 'event') { - const event = (baseMsg as unknown as DebugProtocol.Event).event; + const event = ((baseMsg as unknown) as DebugProtocol.Event).event; if (event === 'stopped') { - const msg = baseMsg as unknown as DebugProtocol.StoppedEvent; + const msg = (baseMsg as unknown) as DebugProtocol.StoppedEvent; this.stopped = { breakpoint: msg.body.reason === 'breakpoint', - threadId: msg.body.threadId as unknown as number, + threadId: (msg.body.threadId as unknown) as number, }; } else { // For now there aren't any other events we care about. diff --git a/extensions/positron-python/src/test/environmentApi.unit.test.ts b/extensions/positron-python/src/test/environmentApi.unit.test.ts index 70ae81c3bdd..012e1a0bfc6 100644 --- a/extensions/positron-python/src/test/environmentApi.unit.test.ts +++ b/extensions/positron-python/src/test/environmentApi.unit.test.ts @@ -133,7 +133,7 @@ suite('Python Environment API', () => { test('getEnvironmentVariables: With WorkspaceFolder resource', async () => { const resource = Uri.file('x'); - const folder = { uri: resource } as unknown as WorkspaceFolder; + const folder = ({ uri: resource } as unknown) as WorkspaceFolder; const envVars = { PATH: 'path' }; envVarsProvider.setup((e) => e.getEnvironmentVariablesSync(resource)).returns(() => envVars); const vars = environmentApi.getEnvironmentVariables(folder); @@ -156,7 +156,7 @@ suite('Python Environment API', () => { const pythonPath = 'this/is/a/test/path'; configService .setup((c) => c.getSettings(undefined)) - .returns(() => ({ pythonPath }) as unknown as IPythonSettings); + .returns(() => (({ pythonPath } as unknown) as IPythonSettings)); const actual = environmentApi.getActiveEnvironmentPath(); assert.deepEqual(actual, { id: normCasePath(pythonPath), @@ -168,7 +168,7 @@ suite('Python Environment API', () => { const pythonPath = 'python'; configService .setup((c) => c.getSettings(undefined)) - .returns(() => ({ pythonPath }) as unknown as IPythonSettings); + .returns(() => (({ pythonPath } as unknown) as IPythonSettings)); const actual = environmentApi.getActiveEnvironmentPath(); assert.deepEqual(actual, { id: 'DEFAULT_PYTHON', @@ -181,7 +181,7 @@ suite('Python Environment API', () => { const resource = Uri.file(__filename); configService .setup((c) => c.getSettings(resource)) - .returns(() => ({ pythonPath }) as unknown as IPythonSettings); + .returns(() => (({ pythonPath } as unknown) as IPythonSettings)); const actual = environmentApi.getActiveEnvironmentPath(resource); assert.deepEqual(actual, { id: normCasePath(pythonPath), diff --git a/extensions/positron-python/src/test/extensionSettings.ts b/extensions/positron-python/src/test/extensionSettings.ts index e5f581416dd..66a77589a77 100644 --- a/extensions/positron-python/src/test/extensionSettings.ts +++ b/extensions/positron-python/src/test/extensionSettings.ts @@ -36,8 +36,7 @@ export function getExtensionSettings(resource: Uri | undefined): IPythonSettings return undefined; } } - const pythonSettings = - require('../client/common/configSettings') as typeof import('../client/common/configSettings'); + const pythonSettings = require('../client/common/configSettings') as typeof import('../client/common/configSettings'); const workspaceService = new WorkspaceService(); const workspaceMemento = new MockMemento(); const globalMemento = new MockMemento(); diff --git a/extensions/positron-python/src/test/initialize.ts b/extensions/positron-python/src/test/initialize.ts index 795eb2b1ef7..8430f5781d2 100644 --- a/extensions/positron-python/src/test/initialize.ts +++ b/extensions/positron-python/src/test/initialize.ts @@ -50,7 +50,7 @@ export async function initialize(): Promise { initializePositron(); // --- End Positron --- - return api as any as IExtensionTestApi; + return (api as any) as IExtensionTestApi; } export async function activateExtension() { const extension = vscode.extensions.getExtension(PVSC_EXTENSION_ID_FOR_TESTS)!; diff --git a/extensions/positron-python/src/test/install/channelManager.channels.test.ts b/extensions/positron-python/src/test/install/channelManager.channels.test.ts index 11c3d90304a..0d8190f046a 100644 --- a/extensions/positron-python/src/test/install/channelManager.channels.test.ts +++ b/extensions/positron-python/src/test/install/channelManager.channels.test.ts @@ -81,7 +81,9 @@ suite('Installation - installation channels', () => { .callback((i: string[]) => { items = i; }) - .returns(() => new Promise((resolve, _reject) => resolve(undefined))); + .returns( + () => new Promise((resolve, _reject) => resolve(undefined)), + ); installer1.setup((x) => x.displayName).returns(() => 'Name 1'); installer2.setup((x) => x.displayName).returns(() => 'Name 2'); @@ -99,7 +101,9 @@ suite('Installation - installation channels', () => { const installer = TypeMoq.Mock.ofType(); installer .setup((x) => x.isSupported(TypeMoq.It.isAny())) - .returns(() => new Promise((resolve) => resolve(supported))); + .returns( + () => new Promise((resolve) => resolve(supported)), + ); installer.setup((x) => x.priority).returns(() => priority || 0); serviceManager.addSingletonInstance(IModuleInstaller, installer.object, name); return installer; diff --git a/extensions/positron-python/src/test/install/channelManager.messages.test.ts b/extensions/positron-python/src/test/install/channelManager.messages.test.ts index bfc4cbecfa8..326ba1ad4bf 100644 --- a/extensions/positron-python/src/test/install/channelManager.messages.test.ts +++ b/extensions/positron-python/src/test/install/channelManager.messages.test.ts @@ -160,7 +160,9 @@ suite('Installation - channel messages', () => { }; interpreters .setup((x) => x.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => new Promise((resolve, _reject) => resolve(activeInterpreter))); + .returns( + () => new Promise((resolve, _reject) => resolve(activeInterpreter)), + ); const channels = new InstallationChannelManager(serviceContainer); let url = ''; @@ -172,7 +174,9 @@ suite('Installation - channel messages', () => { message = m; search = s; }) - .returns(() => new Promise((resolve, _reject) => resolve(search))); + .returns( + () => new Promise((resolve, _reject) => resolve(search)), + ); appShell .setup((x) => x.openUrl(TypeMoq.It.isAnyString())) .callback((s: string) => { diff --git a/extensions/positron-python/src/test/interpreters/activation/indicatorPrompt.unit.test.ts b/extensions/positron-python/src/test/interpreters/activation/indicatorPrompt.unit.test.ts index e2da6ca2514..1de55a46251 100644 --- a/extensions/positron-python/src/test/interpreters/activation/indicatorPrompt.unit.test.ts +++ b/extensions/positron-python/src/test/interpreters/activation/indicatorPrompt.unit.test.ts @@ -43,20 +43,20 @@ suite('Terminal Activation Indicator Prompt', () => { shell = mock(); terminalManager = mock(); interpreterService = mock(); - when(interpreterService.getActiveInterpreter(anything())).thenResolve({ + when(interpreterService.getActiveInterpreter(anything())).thenResolve(({ envName, type, - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); experimentService = mock(); activeResourceService = mock(); persistentStateFactory = mock(); terminalEnvVarCollectionService = mock(); configurationService = mock(); - when(configurationService.getSettings(anything())).thenReturn({ + when(configurationService.getSettings(anything())).thenReturn(({ terminal: { activateEnvironment: true, }, - } as unknown as IPythonSettings); + } as unknown) as IPythonSettings); notificationEnabled = mock>(); terminalEventEmitter = new EventEmitter(); when(persistentStateFactory.createGlobalPersistentState(anything(), true)).thenReturn( @@ -79,11 +79,11 @@ suite('Terminal Activation Indicator Prompt', () => { test('Show notification when a new terminal is opened for which there is no prompt set', async () => { const resource = Uri.file('a'); - const terminal = { + const terminal = ({ creationOptions: { cwd: resource, }, - } as unknown as Terminal; + } as unknown) as Terminal; when(terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource)).thenReturn(false); when(notificationEnabled.value).thenReturn(true); when(shell.showInformationMessage(expectedMessage, ...prompts)).thenResolve(undefined); @@ -97,17 +97,17 @@ suite('Terminal Activation Indicator Prompt', () => { test('Do not show notification if automatic terminal activation is turned off', async () => { reset(configurationService); - when(configurationService.getSettings(anything())).thenReturn({ + when(configurationService.getSettings(anything())).thenReturn(({ terminal: { activateEnvironment: false, }, - } as unknown as IPythonSettings); + } as unknown) as IPythonSettings); const resource = Uri.file('a'); - const terminal = { + const terminal = ({ creationOptions: { cwd: resource, }, - } as unknown as Terminal; + } as unknown) as Terminal; when(terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource)).thenReturn(false); when(notificationEnabled.value).thenReturn(true); when(shell.showInformationMessage(expectedMessage, ...prompts)).thenResolve(undefined); @@ -127,11 +127,11 @@ suite('Terminal Activation Indicator Prompt', () => { // --- End Positron --- const resource = Uri.file('a'); - const terminal = { + const terminal = ({ creationOptions: { cwd: resource, }, - } as unknown as Terminal; + } as unknown) as Terminal; when(terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource)).thenReturn(false); when(notificationEnabled.value).thenReturn(true); when(shell.showInformationMessage(expectedMessage, ...prompts)).thenResolve(undefined); @@ -147,11 +147,11 @@ suite('Terminal Activation Indicator Prompt', () => { test('Do not show notification if notification is disabled', async () => { const resource = Uri.file('a'); - const terminal = { + const terminal = ({ creationOptions: { cwd: resource, }, - } as unknown as Terminal; + } as unknown) as Terminal; when(terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource)).thenReturn(false); when(notificationEnabled.value).thenReturn(false); when(shell.showInformationMessage(expectedMessage, ...prompts)).thenResolve(undefined); @@ -165,11 +165,11 @@ suite('Terminal Activation Indicator Prompt', () => { test('Do not show notification when a new terminal is opened for which there is prompt set', async () => { const resource = Uri.file('a'); - const terminal = { + const terminal = ({ creationOptions: { cwd: resource, }, - } as unknown as Terminal; + } as unknown) as Terminal; when(terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource)).thenReturn(true); when(notificationEnabled.value).thenReturn(true); when(shell.showInformationMessage(expectedMessage, ...prompts)).thenResolve(undefined); @@ -183,11 +183,11 @@ suite('Terminal Activation Indicator Prompt', () => { test("Disable notification if `Don't show again` is clicked", async () => { const resource = Uri.file('a'); - const terminal = { + const terminal = ({ creationOptions: { cwd: resource, }, - } as unknown as Terminal; + } as unknown) as Terminal; when(terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource)).thenReturn(false); when(notificationEnabled.value).thenReturn(true); when(notificationEnabled.updateValue(false)).thenResolve(); @@ -204,11 +204,11 @@ suite('Terminal Activation Indicator Prompt', () => { test('Do not disable notification if prompt is closed', async () => { const resource = Uri.file('a'); - const terminal = { + const terminal = ({ creationOptions: { cwd: resource, }, - } as unknown as Terminal; + } as unknown) as Terminal; when(terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource)).thenReturn(false); when(notificationEnabled.value).thenReturn(true); when(notificationEnabled.updateValue(false)).thenResolve(); diff --git a/extensions/positron-python/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts b/extensions/positron-python/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts index 35b7dccb6be..faa95a08a3c 100644 --- a/extensions/positron-python/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts +++ b/extensions/positron-python/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts @@ -96,10 +96,10 @@ suite('Terminal Environment Variable Collection Service', () => { process.env, ); configService = mock(); - when(configService.getSettings(anything())).thenReturn({ + when(configService.getSettings(anything())).thenReturn(({ terminal: { activateEnvironment: true }, pythonPath: displayPath, - } as unknown as IPythonSettings); + } as unknown) as IPythonSettings); when(collection.clear()).thenResolve(); terminalEnvVarCollectionService = new TerminalEnvVarCollectionService( instance(platform), @@ -222,9 +222,9 @@ suite('Terminal Environment Variable Collection Service', () => { environmentActivationService.getActivatedEnvironmentVariables(anything(), undefined, undefined, 'bash'), ).thenResolve(envVars); - when(interpreterService.getActiveInterpreter(anything())).thenResolve({ + when(interpreterService.getActiveInterpreter(anything())).thenResolve(({ envName: 'envName', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(collection.replace(anything(), anything(), anything())).thenResolve(); when(collection.delete(anything())).thenResolve(); @@ -250,11 +250,11 @@ suite('Terminal Environment Variable Collection Service', () => { when( environmentActivationService.getActivatedEnvironmentVariables(anything(), undefined, undefined, 'bash'), ).thenResolve(envVars); - when(interpreterService.getActiveInterpreter(anything())).thenResolve({ + when(interpreterService.getActiveInterpreter(anything())).thenResolve(({ type: PythonEnvType.Virtual, envName: 'envName', envPath: 'prefix/to/conda', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(collection.replace(anything(), anything(), anything())).thenResolve(); when(collection.delete(anything())).thenResolve(); @@ -274,11 +274,11 @@ suite('Terminal Environment Variable Collection Service', () => { when( environmentActivationService.getActivatedEnvironmentVariables(anything(), undefined, undefined, 'bash'), ).thenResolve(envVars); - when(interpreterService.getActiveInterpreter(anything())).thenResolve({ + when(interpreterService.getActiveInterpreter(anything())).thenResolve(({ type: PythonEnvType.Virtual, envName: 'envName', envPath: 'prefix/to/conda', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(collection.replace(anything(), anything(), anything())).thenResolve(); when(collection.delete(anything())).thenResolve(); @@ -299,11 +299,11 @@ suite('Terminal Environment Variable Collection Service', () => { when( environmentActivationService.getActivatedEnvironmentVariables(anything(), undefined, undefined, 'bash'), ).thenResolve(envVars); - when(interpreterService.getActiveInterpreter(anything())).thenResolve({ + when(interpreterService.getActiveInterpreter(anything())).thenResolve(({ type: PythonEnvType.Conda, envName: 'envName', envPath: 'prefix/to/conda', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(collection.replace(anything(), anything(), anything())).thenResolve(); when(collection.delete(anything())).thenResolve(); @@ -470,10 +470,10 @@ suite('Terminal Environment Variable Collection Service', () => { when(collection.replace(anything(), anything(), anything())).thenResolve(); when(collection.delete(anything())).thenResolve(); reset(configService); - when(configService.getSettings(anything())).thenReturn({ + when(configService.getSettings(anything())).thenReturn(({ terminal: { activateEnvironment: false }, pythonPath: displayPath, - } as unknown as IPythonSettings); + } as unknown) as IPythonSettings); await terminalEnvVarCollectionService._applyCollection(undefined, customShell); @@ -517,9 +517,9 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: PythonEnvType.Virtual, - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, ps1Shell), @@ -545,9 +545,9 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: PythonEnvType.Virtual, - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, ps1Shell), @@ -571,11 +571,11 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: PythonEnvType.Conda, envName: 'envName', envPath: 'prefix/to/conda', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, ps1Shell), @@ -603,11 +603,11 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: PythonEnvType.Conda, envName: 'base', envPath: 'prefix/to/conda', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, ps1Shell), @@ -631,11 +631,11 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: PythonEnvType.Conda, envName: 'envName', envPath: 'prefix/to/conda', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, ps1Shell), @@ -658,9 +658,9 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: undefined, - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, ps1Shell), @@ -684,9 +684,9 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: PythonEnvType.Virtual, - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, windowsShell), @@ -710,9 +710,9 @@ suite('Terminal Environment Variable Collection Service', () => { name: 'workspace1', index: 0, }; - when(interpreterService.getActiveInterpreter(resource)).thenResolve({ + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ type: PythonEnvType.Virtual, - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); when( environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, windowsShell), diff --git a/extensions/positron-python/src/test/interpreters/display.unit.test.ts b/extensions/positron-python/src/test/interpreters/display.unit.test.ts index 86690b0d8fe..3537425f2ef 100644 --- a/extensions/positron-python/src/test/interpreters/display.unit.test.ts +++ b/extensions/positron-python/src/test/interpreters/display.unit.test.ts @@ -231,10 +231,10 @@ suite('Interpreters Display', () => { const expectedDisplayName = '3.10.1'; setupWorkspaceFolder(resource, workspaceFolder); - const pythonInterpreter: PythonEnvironment = { + const pythonInterpreter: PythonEnvironment = ({ detailedDisplayName: displayName, path: pythonPath, - } as any as PythonEnvironment; + } as any) as PythonEnvironment; interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isValue(workspaceFolder))) .returns(() => Promise.resolve(pythonInterpreter)); diff --git a/extensions/positron-python/src/test/interpreters/interpreterService.unit.test.ts b/extensions/positron-python/src/test/interpreters/interpreterService.unit.test.ts index 3079886d31a..d8a0ada23a6 100644 --- a/extensions/positron-python/src/test/interpreters/interpreterService.unit.test.ts +++ b/extensions/positron-python/src/test/interpreters/interpreterService.unit.test.ts @@ -252,7 +252,7 @@ suite('Interpreters service', () => { workspace.setup((w) => w.getWorkspaceFolder(resource)).returns(() => workspaceFolder); service._pythonPathSetting = ''; configService.reset(); - configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'current path' }) as any); + configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'current path' } as any)); interpreterDisplay .setup((i) => i.refresh()) .returns(() => Promise.resolve()) @@ -272,7 +272,7 @@ suite('Interpreters service', () => { workspace.setup((w) => w.getWorkspaceFolder(resource)).returns(() => workspaceFolder); service._pythonPathSetting = 'stored setting'; configService.reset(); - configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'current path' }) as any); + configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'current path' } as any)); interpreterDisplay .setup((i) => i.refresh()) .returns(() => Promise.resolve()) @@ -290,7 +290,7 @@ suite('Interpreters service', () => { const resource = Uri.parse('a'); service._pythonPathSetting = 'setting'; configService.reset(); - configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'setting' }) as any); + configService.setup((c) => c.getSettings(resource)).returns(() => ({ pythonPath: 'setting' } as any)); interpreterDisplay .setup((i) => i.refresh()) .returns(() => Promise.resolve()) diff --git a/extensions/positron-python/src/test/interpreters/virtualEnvs/activatedEnvLaunch.unit.test.ts b/extensions/positron-python/src/test/interpreters/virtualEnvs/activatedEnvLaunch.unit.test.ts index aa0607c50b9..2ebdecd000d 100644 --- a/extensions/positron-python/src/test/interpreters/virtualEnvs/activatedEnvLaunch.unit.test.ts +++ b/extensions/positron-python/src/test/interpreters/virtualEnvs/activatedEnvLaunch.unit.test.ts @@ -74,7 +74,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'env' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'env' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -107,7 +107,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'env' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'env' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -140,7 +140,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_AUTO_ACTIVATE_BASE = 'false'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -173,7 +173,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_AUTO_ACTIVATE_BASE = 'true'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -205,7 +205,7 @@ suite('Activated Env Launch', async () => { process.env.VIRTUAL_ENV = virtualEnvPrefix; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -237,7 +237,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'env' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'env' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); workspaceService.setup((w) => w.workspaceFolders).returns(() => []); pythonPathUpdaterService @@ -267,7 +267,7 @@ suite('Activated Env Launch', async () => { process.env.VIRTUAL_ENV = virtualEnvPrefix; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => uri); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -346,7 +346,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -368,7 +368,9 @@ suite('Activated Env Launch', async () => { processService .setup((p) => p.shellExec('conda config --get auto_activate_base')) .returns(() => - Promise.resolve({ stdout: '--set auto_activate_base False' } as unknown as ExecutionResult), + Promise.resolve(({ stdout: '--set auto_activate_base False' } as unknown) as ExecutionResult< + string + >), ); activatedEnvLaunch = new ActivatedEnvironmentLaunch( workspaceService.object, @@ -386,7 +388,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -407,7 +409,9 @@ suite('Activated Env Launch', async () => { processService .setup((p) => p.shellExec('conda config --get auto_activate_base')) .returns(() => - Promise.resolve({ stdout: '--set auto_activate_base False' } as unknown as ExecutionResult), + Promise.resolve(({ stdout: '--set auto_activate_base False' } as unknown) as ExecutionResult< + string + >), ); activatedEnvLaunch = new ActivatedEnvironmentLaunch( workspaceService.object, @@ -425,7 +429,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -446,7 +450,9 @@ suite('Activated Env Launch', async () => { processService .setup((p) => p.shellExec('conda config --get auto_activate_base')) .returns(() => - Promise.resolve({ stdout: '--set auto_activate_base False' } as unknown as ExecutionResult), + Promise.resolve(({ stdout: '--set auto_activate_base False' } as unknown) as ExecutionResult< + string + >), ); activatedEnvLaunch = new ActivatedEnvironmentLaunch( workspaceService.object, @@ -464,7 +470,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -475,7 +481,9 @@ suite('Activated Env Launch', async () => { processService .setup((p) => p.shellExec('conda config --get auto_activate_base')) .returns(() => - Promise.resolve({ stdout: '--set auto_activate_base True' } as unknown as ExecutionResult), + Promise.resolve(({ stdout: '--set auto_activate_base True' } as unknown) as ExecutionResult< + string + >), ); activatedEnvLaunch = new ActivatedEnvironmentLaunch( workspaceService.object, @@ -493,7 +501,7 @@ suite('Activated Env Launch', async () => { process.env.CONDA_SHLVL = '1'; interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'nonbase' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'nonbase' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -504,7 +512,9 @@ suite('Activated Env Launch', async () => { processService .setup((p) => p.shellExec('conda config --get auto_activate_base')) .returns(() => - Promise.resolve({ stdout: '--set auto_activate_base False' } as unknown as ExecutionResult), + Promise.resolve(({ stdout: '--set auto_activate_base False' } as unknown) as ExecutionResult< + string + >), ); activatedEnvLaunch = new ActivatedEnvironmentLaunch( workspaceService.object, @@ -520,7 +530,7 @@ suite('Activated Env Launch', async () => { test('Do not show prompt if conda environment is not activated', async () => { interpreterService .setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ envName: 'base' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment)); workspaceService.setup((w) => w.workspaceFile).returns(() => undefined); const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 }; workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]); @@ -531,7 +541,9 @@ suite('Activated Env Launch', async () => { processService .setup((p) => p.shellExec('conda config --get auto_activate_base')) .returns(() => - Promise.resolve({ stdout: '--set auto_activate_base False' } as unknown as ExecutionResult), + Promise.resolve(({ stdout: '--set auto_activate_base False' } as unknown) as ExecutionResult< + string + >), ); activatedEnvLaunch = new ActivatedEnvironmentLaunch( workspaceService.object, diff --git a/extensions/positron-python/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts b/extensions/positron-python/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts index 817a25bfe27..2ad67831c45 100644 --- a/extensions/positron-python/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts +++ b/extensions/positron-python/src/test/interpreters/virtualEnvs/virtualEnvPrompt.unit.test.ts @@ -47,10 +47,10 @@ suite('Virtual Environment Prompt', () => { interpreterService = mock(); isCreatingEnvironmentStub = sinon.stub(createEnvApi, 'isCreatingEnvironment'); isCreatingEnvironmentStub.returns(false); - when(interpreterService.getActiveInterpreter(anything())).thenResolve({ + when(interpreterService.getActiveInterpreter(anything())).thenResolve(({ id: 'selected', path: 'path/to/selected', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); disposable = mock(Disposable); appShell = mock(ApplicationShell); environmentPrompt = new VirtualEnvironmentPromptTest( @@ -110,7 +110,7 @@ suite('Virtual Environment Prompt', () => { when(helper.getBestInterpreter(deepEqual([interpreter1, interpreter2] as any))).thenReturn(interpreter2 as any); reset(interpreterService); when(interpreterService.getActiveInterpreter(anything())).thenResolve( - interpreter2 as unknown as PythonEnvironment, + (interpreter2 as unknown) as PythonEnvironment, ); when(persistentStateFactory.createWorkspacePersistentState(anything(), true)).thenReturn( notificationPromptEnabled.object, diff --git a/extensions/positron-python/src/test/languageServer/jediLSExtensionManager.unit.test.ts b/extensions/positron-python/src/test/languageServer/jediLSExtensionManager.unit.test.ts index 32deb3db0c9..b57a0bbd096 100644 --- a/extensions/positron-python/src/test/languageServer/jediLSExtensionManager.unit.test.ts +++ b/extensions/positron-python/src/test/languageServer/jediLSExtensionManager.unit.test.ts @@ -24,11 +24,11 @@ suite('Language Server - Jedi LS extension manager', () => { {} as IInterpreterPathService, {} as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, ); }); @@ -38,9 +38,9 @@ suite('Language Server - Jedi LS extension manager', () => { }); test('canStartLanguageServer should return true if an interpreter is passed in', () => { - const result = manager.canStartLanguageServer({ + const result = manager.canStartLanguageServer(({ path: 'path/to/interpreter', - } as unknown as PythonEnvironment); + } as unknown) as PythonEnvironment); assert.strictEqual(result, true); }); diff --git a/extensions/positron-python/src/test/languageServer/pylanceLSExtensionManager.unit.test.ts b/extensions/positron-python/src/test/languageServer/pylanceLSExtensionManager.unit.test.ts index 79e02223f8f..751b26d37d3 100644 --- a/extensions/positron-python/src/test/languageServer/pylanceLSExtensionManager.unit.test.ts +++ b/extensions/positron-python/src/test/languageServer/pylanceLSExtensionManager.unit.test.ts @@ -29,11 +29,11 @@ suite('Language Server - Pylance LS extension manager', () => { {} as IInterpreterPathService, {} as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ registerCommand: () => { /** do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, {} as IExtensions, {} as IApplicationShell, @@ -55,15 +55,15 @@ suite('Language Server - Pylance LS extension manager', () => { {} as IInterpreterPathService, {} as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ registerCommand: () => { /** do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => ({}), - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, ); @@ -82,15 +82,15 @@ suite('Language Server - Pylance LS extension manager', () => { {} as IInterpreterPathService, {} as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, ); diff --git a/extensions/positron-python/src/test/languageServer/watcher.unit.test.ts b/extensions/positron-python/src/test/languageServer/watcher.unit.test.ts index 42b17bec610..e86e19cf205 100644 --- a/extensions/positron-python/src/test/languageServer/watcher.unit.test.ts +++ b/extensions/positron-python/src/test/languageServer/watcher.unit.test.ts @@ -42,22 +42,22 @@ suite('Language server watcher', () => { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => 'python', onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { /* do nothing */ @@ -65,19 +65,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -98,18 +98,18 @@ suite('Language server watcher', () => { } as IConfigurationService, {} as IExperimentService, {} as IInterpreterHelper, - { + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ isTrusted: true, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -118,15 +118,15 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, + } as unknown) as IWorkspaceService, {} as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -143,18 +143,18 @@ suite('Language server watcher', () => { } as IConfigurationService, {} as IExperimentService, {} as IInterpreterHelper, - { + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ isTrusted: false, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -163,15 +163,15 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, + } as unknown) as IWorkspaceService, {} as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -194,39 +194,39 @@ suite('Language server watcher', () => { getActiveInterpreterStub.onFirstCall().returns('python'); getActiveInterpreterStub.onSecondCall().returns('other/python'); - const interpreterService = { + const interpreterService = ({ getActiveInterpreter: getActiveInterpreterStub, onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService; + } as unknown) as IInterpreterService; watcher = new LanguageServerWatcher( - { + ({ get: () => { /* do nothing */ }, - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, {} as ILanguageServerOutputChannel, { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, + } as unknown) as IInterpreterPathService, interpreterService, - { + ({ onDidEnvironmentVariablesChange: () => { /* do nothing */ }, - } as unknown as IEnvironmentVariablesProvider, - { + } as unknown) as IEnvironmentVariablesProvider, + ({ isTrusted: true, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -235,19 +235,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -288,22 +288,22 @@ suite('Language server watcher', () => { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => ({ folderUri: Uri.parse('workspace') }), - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => 'python', onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { /* do nothing */ @@ -311,19 +311,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -358,7 +358,7 @@ suite('Language server watcher', () => { test('When the config settings change, but the python.languageServer setting is not affected, the watcher should not restart the language server', async () => { let onDidChangeConfigListener: (event: ConfigurationChangeEvent) => Promise = () => Promise.resolve(); - const workspaceService = { + const workspaceService = ({ getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: (listener: (event: ConfigurationChangeEvent) => Promise) => { onDidChangeConfigListener = listener; @@ -366,7 +366,7 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService; + } as unknown) as IWorkspaceService; watcher = new LanguageServerWatcher( {} as IServiceContainer, @@ -375,34 +375,34 @@ suite('Language server watcher', () => { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => 'python', onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, workspaceService, - { + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -420,7 +420,7 @@ suite('Language server watcher', () => { test('When the config settings change, and the python.languageServer setting is affected, the watcher should restart the language server', async () => { let onDidChangeConfigListener: (event: ConfigurationChangeEvent) => Promise = () => Promise.resolve(); - const workspaceService = { + const workspaceService = ({ getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: (listener: (event: ConfigurationChangeEvent) => Promise) => { onDidChangeConfigListener = listener; @@ -429,49 +429,49 @@ suite('Language server watcher', () => { /* do nothing */ }, workspaceFolders: [{ uri: Uri.parse('workspace') }], - } as unknown as IWorkspaceService; + } as unknown) as IWorkspaceService; const getSettingsStub = sandbox.stub(); getSettingsStub.onFirstCall().returns({ languageServer: LanguageServerType.None }); getSettingsStub.onSecondCall().returns({ languageServer: LanguageServerType.Node }); - const configService = { + const configService = ({ getSettings: getSettingsStub, - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; watcher = new LanguageServerWatcher( {} as IServiceContainer, {} as ILanguageServerOutputChannel, configService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => 'python', onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, workspaceService, - { + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -499,22 +499,22 @@ suite('Language server watcher', () => { getSettings: () => ({ languageServer: LanguageServerType.Jedi }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => ({ version: { major: 2, minor: 7 } }), onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { /* do nothing */ @@ -522,19 +522,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -560,22 +560,22 @@ suite('Language server watcher', () => { }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => ({ version: { major: 2, minor: 7 } }), onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { /* do nothing */ @@ -583,22 +583,22 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, - { + } as unknown) as IExtensions, + ({ showWarningMessage: () => Promise.resolve(undefined), - } as unknown as IApplicationShell, + } as unknown) as IApplicationShell, disposables, ); watcher.register(); @@ -619,22 +619,22 @@ suite('Language server watcher', () => { getSettings: () => ({ languageServer: LanguageServerType.Jedi }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => ({ version: { major: 2, minor: 7 } }), onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ isTrusted: false, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -643,19 +643,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -706,22 +706,22 @@ suite('Language server watcher', () => { getSettings: () => ({ languageServer }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: getActiveInterpreterStub, onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, - { + ({ isTrusted: true, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -730,22 +730,22 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, - { + } as unknown) as IExtensions, + ({ showWarningMessage: () => Promise.resolve(undefined), - } as unknown as IApplicationShell, + } as unknown) as IApplicationShell, disposables, ); watcher.register(); @@ -775,7 +775,7 @@ suite('Language server watcher', () => { let onDidChangeWorkspaceFoldersListener: (event: WorkspaceFoldersChangeEvent) => Promise = () => Promise.resolve(); - const workspaceService = { + const workspaceService = ({ getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { /* do nothing */ @@ -785,7 +785,7 @@ suite('Language server watcher', () => { }, workspaceFolders: [{ uri: Uri.parse('workspace1') }, { uri: Uri.parse('workspace2') }], isTrusted: true, - } as unknown as IWorkspaceService; + } as unknown) as IWorkspaceService; watcher = new LanguageServerWatcher( {} as IServiceContainer, @@ -794,37 +794,37 @@ suite('Language server watcher', () => { getSettings: () => ({ languageServer }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, - { + } as unknown) as IInterpreterPathService, + ({ getActiveInterpreter: () => ({ version: { major: 3, minor: 7 } }), onDidChangeInterpreterInformation: () => { /* do nothing */ }, - } as unknown as IInterpreterService, + } as unknown) as IInterpreterService, {} as IEnvironmentVariablesProvider, workspaceService, - { + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, - { + } as unknown) as IExtensions, + ({ showWarningMessage: () => Promise.resolve(undefined), - } as unknown as IApplicationShell, + } as unknown) as IApplicationShell, disposables, ); watcher.register(); @@ -845,14 +845,14 @@ suite('Language server watcher', () => { }); test('The language server should be restarted if the interpreter info changed', async () => { - const info = { + const info = ({ envPath: 'foo', path: 'path/to/foo/bin/python', - } as unknown as PythonEnvironment; + } as unknown) as PythonEnvironment; let onDidChangeInfoListener: (event: PythonEnvironment) => Promise = () => Promise.resolve(); - const interpreterService = { + const interpreterService = ({ onDidChangeInterpreterInformation: ( listener: (event: PythonEnvironment) => Promise, thisArg: unknown, @@ -863,34 +863,34 @@ suite('Language server watcher', () => { envPath: 'foo', path: 'path/to/foo', }), - } as unknown as IInterpreterService; + } as unknown) as IInterpreterService; watcher = new LanguageServerWatcher( - { + ({ get: () => { /* do nothing */ }, - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, {} as ILanguageServerOutputChannel, { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, + } as unknown) as IInterpreterPathService, interpreterService, - { + ({ onDidEnvironmentVariablesChange: () => { /* do nothing */ }, - } as unknown as IEnvironmentVariablesProvider, - { + } as unknown) as IEnvironmentVariablesProvider, + ({ isTrusted: true, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -899,19 +899,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -928,14 +928,14 @@ suite('Language server watcher', () => { }); test('The language server should not be restarted if the interpreter info did not change', async () => { - const info = { + const info = ({ envPath: 'foo', path: 'path/to/foo', - } as unknown as PythonEnvironment; + } as unknown) as PythonEnvironment; let onDidChangeInfoListener: (event: PythonEnvironment) => Promise = () => Promise.resolve(); - const interpreterService = { + const interpreterService = ({ onDidChangeInterpreterInformation: ( listener: (event: PythonEnvironment) => Promise, thisArg: unknown, @@ -943,34 +943,34 @@ suite('Language server watcher', () => { onDidChangeInfoListener = listener.bind(thisArg); }, getActiveInterpreter: () => info, - } as unknown as IInterpreterService; + } as unknown) as IInterpreterService; watcher = new LanguageServerWatcher( - { + ({ get: () => { /* do nothing */ }, - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, {} as ILanguageServerOutputChannel, { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, + } as unknown) as IInterpreterPathService, interpreterService, - { + ({ onDidEnvironmentVariablesChange: () => { /* do nothing */ }, - } as unknown as IEnvironmentVariablesProvider, - { + } as unknown) as IEnvironmentVariablesProvider, + ({ isTrusted: true, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -979,19 +979,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -1008,14 +1008,14 @@ suite('Language server watcher', () => { }); test('The language server should not be restarted if the interpreter info changed but the env path is an empty string', async () => { - const info = { + const info = ({ envPath: '', path: 'path/to/foo', - } as unknown as PythonEnvironment; + } as unknown) as PythonEnvironment; let onDidChangeInfoListener: (event: PythonEnvironment) => Promise = () => Promise.resolve(); - const interpreterService = { + const interpreterService = ({ onDidChangeInterpreterInformation: ( listener: (event: PythonEnvironment) => Promise, thisArg: unknown, @@ -1026,34 +1026,34 @@ suite('Language server watcher', () => { envPath: 'foo', path: 'path/to/foo', }), - } as unknown as IInterpreterService; + } as unknown) as IInterpreterService; watcher = new LanguageServerWatcher( - { + ({ get: () => { /* do nothing */ }, - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, {} as ILanguageServerOutputChannel, { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, + } as unknown) as IInterpreterPathService, interpreterService, - { + ({ onDidEnvironmentVariablesChange: () => { /* do nothing */ }, - } as unknown as IEnvironmentVariablesProvider, - { + } as unknown) as IEnvironmentVariablesProvider, + ({ isTrusted: true, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -1062,19 +1062,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); @@ -1091,14 +1091,14 @@ suite('Language server watcher', () => { }); test('The language server should not be restarted if the interpreter info changed but the env path is undefined', async () => { - const info = { + const info = ({ envPath: undefined, path: 'path/to/foo', - } as unknown as PythonEnvironment; + } as unknown) as PythonEnvironment; let onDidChangeInfoListener: (event: PythonEnvironment) => Promise = () => Promise.resolve(); - const interpreterService = { + const interpreterService = ({ onDidChangeInterpreterInformation: ( listener: (event: PythonEnvironment) => Promise, thisArg: unknown, @@ -1109,34 +1109,34 @@ suite('Language server watcher', () => { envPath: 'foo', path: 'path/to/foo', }), - } as unknown as IInterpreterService; + } as unknown) as IInterpreterService; watcher = new LanguageServerWatcher( - { + ({ get: () => { /* do nothing */ }, - } as unknown as IServiceContainer, + } as unknown) as IServiceContainer, {} as ILanguageServerOutputChannel, { getSettings: () => ({ languageServer: LanguageServerType.None }), } as IConfigurationService, {} as IExperimentService, - { + ({ getActiveWorkspaceUri: () => undefined, - } as unknown as IInterpreterHelper, - { + } as unknown) as IInterpreterHelper, + ({ onDidChange: () => { /* do nothing */ }, - } as unknown as IInterpreterPathService, + } as unknown) as IInterpreterPathService, interpreterService, - { + ({ onDidEnvironmentVariablesChange: () => { /* do nothing */ }, - } as unknown as IEnvironmentVariablesProvider, - { + } as unknown) as IEnvironmentVariablesProvider, + ({ isTrusted: true, getWorkspaceFolder: (uri: Uri) => ({ uri }), onDidChangeConfiguration: () => { @@ -1145,19 +1145,19 @@ suite('Language server watcher', () => { onDidChangeWorkspaceFolders: () => { /* do nothing */ }, - } as unknown as IWorkspaceService, - { + } as unknown) as IWorkspaceService, + ({ registerCommand: () => { /* do nothing */ }, - } as unknown as ICommandManager, + } as unknown) as ICommandManager, {} as IFileSystem, - { + ({ getExtension: () => undefined, onDidChange: () => { /* do nothing */ }, - } as unknown as IExtensions, + } as unknown) as IExtensions, {} as IApplicationShell, disposables, ); diff --git a/extensions/positron-python/src/test/mocks/autoSelector.ts b/extensions/positron-python/src/test/mocks/autoSelector.ts index efc25b227a1..cc4ab4ddb8e 100644 --- a/extensions/positron-python/src/test/mocks/autoSelector.ts +++ b/extensions/positron-python/src/test/mocks/autoSelector.ts @@ -14,8 +14,7 @@ import { PythonEnvironment } from '../../client/pythonEnvironments/info'; @injectable() export class MockAutoSelectionService - implements IInterpreterAutoSelectionService, IInterpreterAutoSelectionProxyService -{ + implements IInterpreterAutoSelectionService, IInterpreterAutoSelectionProxyService { // eslint-disable-next-line class-methods-use-this public async setWorkspaceInterpreter(_resource: Resource, _interpreter: PythonEnvironment): Promise { return Promise.resolve(); diff --git a/extensions/positron-python/src/test/mocks/mockDocument.ts b/extensions/positron-python/src/test/mocks/mockDocument.ts index 3008eae0bbe..811c591420b 100644 --- a/extensions/positron-python/src/test/mocks/mockDocument.ts +++ b/extensions/positron-python/src/test/mocks/mockDocument.ts @@ -15,11 +15,7 @@ class MockLine implements TextLine { private _isEmpty: boolean | undefined; - constructor( - private _contents: string, - private _line: number, - private _offset: number, - ) { + constructor(private _contents: string, private _line: number, private _offset: number) { this._range = new Range(new Position(_line, 0), new Position(_line, _contents.length)); this._rangeWithLineBreak = new Range(this.range.start, new Position(_line, _contents.length + 1)); } diff --git a/extensions/positron-python/src/test/mocks/mockTextEditor.ts b/extensions/positron-python/src/test/mocks/mockTextEditor.ts index b253a31666f..6c1c91f4557 100644 --- a/extensions/positron-python/src/test/mocks/mockTextEditor.ts +++ b/extensions/positron-python/src/test/mocks/mockTextEditor.ts @@ -24,10 +24,7 @@ import { MockDocument } from './mockDocument'; import { IMockDocumentManager, IMockTextEditor } from './mockTypes'; class MockEditorEdit implements TextEditorEdit { - constructor( - private _documentManager: IMockDocumentManager, - private _document: MockDocument, - ) {} + constructor(private _documentManager: IMockDocumentManager, private _document: MockDocument) {} public replace(location: Selection | Range | Position, value: string): void { this._documentManager.changeDocument(this._document.fileName, [ @@ -65,10 +62,7 @@ export class MockEditor implements IMockTextEditor { private _revealCallback: () => void; - constructor( - private _documentManager: IMockDocumentManager, - private _document: MockDocument, - ) { + constructor(private _documentManager: IMockDocumentManager, private _document: MockDocument) { this.selection = new Selection(0, 0, 0, 0); this._revealCallback = noop; } diff --git a/extensions/positron-python/src/test/mocks/moduleInstaller.ts b/extensions/positron-python/src/test/mocks/moduleInstaller.ts index 80b34156871..fb183e6ebd9 100644 --- a/extensions/positron-python/src/test/mocks/moduleInstaller.ts +++ b/extensions/positron-python/src/test/mocks/moduleInstaller.ts @@ -5,10 +5,7 @@ import { Product } from '../../client/common/types'; import { ModuleInstallerType } from '../../client/pythonEnvironments/info'; export class MockModuleInstaller extends EventEmitter implements IModuleInstaller { - constructor( - public readonly displayName: string, - private supported: boolean, - ) { + constructor(public readonly displayName: string, private supported: boolean) { super(); } diff --git a/extensions/positron-python/src/test/mocks/vsc/arrays.ts b/extensions/positron-python/src/test/mocks/vsc/arrays.ts index 2944d872021..c06cefa7c27 100644 --- a/extensions/positron-python/src/test/mocks/vsc/arrays.ts +++ b/extensions/positron-python/src/test/mocks/vsc/arrays.ts @@ -367,7 +367,7 @@ export function index(array: T[], indexer: (t: T) => string, merger?: (t: export function index( array: T[], indexer: (t: T) => string, - merger: (t: T, r: R) => R = (t) => t as unknown as R, + merger: (t: T, r: R) => R = (t) => (t as unknown) as R, ): Record { return array.reduce((r, t) => { const key = indexer(t); diff --git a/extensions/positron-python/src/test/mocks/vsc/extHostedTypes.ts b/extensions/positron-python/src/test/mocks/vsc/extHostedTypes.ts index 2288352525f..f87b5017415 100644 --- a/extensions/positron-python/src/test/mocks/vsc/extHostedTypes.ts +++ b/extensions/positron-python/src/test/mocks/vsc/extHostedTypes.ts @@ -450,12 +450,12 @@ export class Selection extends Range { } toJSON(): [Position, Position] { - return { + return ({ start: this.start, end: this.end, active: this.active, anchor: this.anchor, - } as unknown as [Position, Position]; + } as unknown) as [Position, Position]; } } @@ -648,7 +648,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit { set(uri: vscUri.URI, edits: readonly unknown[]): void { let data = this._textEdits.get(uri.toString()); if (!data) { - data = { seq: (this._seqPool += 1), uri, edits: [] }; + data = { seq: this._seqPool += 1, uri, edits: [] }; this._textEdits.set(uri.toString(), data); } if (!edits) { @@ -884,7 +884,7 @@ export class Diagnostic { toJSON(): { severity: DiagnosticSeverity; message: string; range: Range; source: string; code: string | number } { return { - severity: DiagnosticSeverity[this.severity] as unknown as DiagnosticSeverity, + severity: (DiagnosticSeverity[this.severity] as unknown) as DiagnosticSeverity, message: this.message, range: this.range, source: this.source, @@ -933,7 +933,7 @@ export class DocumentHighlight { toJSON(): { range: Range; kind: DocumentHighlightKind } { return { range: this.range, - kind: DocumentHighlightKind[this.kind] as unknown as DocumentHighlightKind, + kind: (DocumentHighlightKind[this.kind] as unknown) as DocumentHighlightKind, }; } } @@ -1008,7 +1008,7 @@ export class SymbolInformation { toJSON(): { name: string; kind: SymbolKind; location: Location; containerName: string } { return { name: this.name, - kind: SymbolKind[this.kind] as unknown as SymbolKind, + kind: (SymbolKind[this.kind] as unknown) as SymbolKind, location: this.location, containerName: this.containerName, }; @@ -1269,7 +1269,7 @@ export class CompletionItem { return { label: this.label, label2: this.label2, - kind: this.kind && (CompletionItemKind[this.kind] as unknown as CompletionItemKind), + kind: this.kind && ((CompletionItemKind[this.kind] as unknown) as CompletionItemKind), detail: this.detail, documentation: this.documentation, sortText: this.sortText, diff --git a/extensions/positron-python/src/test/mocks/vsc/index.ts b/extensions/positron-python/src/test/mocks/vsc/index.ts index 54705e112e6..7678bef4e53 100644 --- a/extensions/positron-python/src/test/mocks/vsc/index.ts +++ b/extensions/positron-python/src/test/mocks/vsc/index.ts @@ -23,10 +23,7 @@ export class ThemeIcon { static readonly Folder: ThemeIcon; - constructor( - public readonly id: string, - public readonly color?: ThemeColor, - ) {} + constructor(public readonly id: string, public readonly color?: ThemeColor) {} } export class ThemeColor { @@ -109,7 +106,7 @@ export class EventEmitter implements vscode.EventEmitter { public emitter: NodeEventEmitter; constructor() { - this.event = this.add.bind(this) as unknown as vscode.Event; + this.event = (this.add.bind(this) as unknown) as vscode.Event; this.emitter = new NodeEventEmitter(); } @@ -378,10 +375,7 @@ export interface DebugAdapterExecutableOptions { } export class DebugAdapterServer { - constructor( - public readonly port: number, - public readonly host?: string, - ) {} + constructor(public readonly port: number, public readonly host?: string) {} } export class DebugAdapterExecutable { constructor( diff --git a/extensions/positron-python/src/test/proc.ts b/extensions/positron-python/src/test/proc.ts index b3653d5dfd3..8a21eb379f7 100644 --- a/extensions/positron-python/src/test/proc.ts +++ b/extensions/positron-python/src/test/proc.ts @@ -51,7 +51,7 @@ export class Proc { private readonly output: ProcOutput; private result: ProcResult | undefined; constructor(raw: cp.ChildProcess, output: ProcOutput) { - this.raw = raw as unknown as IRawProc; + this.raw = (raw as unknown) as IRawProc; this.output = output; } public get pid(): number | undefined { diff --git a/extensions/positron-python/src/test/providers/codeActionProvider/main.unit.test.ts b/extensions/positron-python/src/test/providers/codeActionProvider/main.unit.test.ts index 227c162f2ae..55644d80ae5 100644 --- a/extensions/positron-python/src/test/providers/codeActionProvider/main.unit.test.ts +++ b/extensions/positron-python/src/test/providers/codeActionProvider/main.unit.test.ts @@ -48,7 +48,7 @@ suite('Code Action Provider service', async () => { pattern: '**/launch.json', }); assert.deepEqual(metadata!, { - providedCodeActionKinds: ['CodeAction' as unknown as CodeActionKind], + providedCodeActionKinds: [('CodeAction' as unknown) as CodeActionKind], }); expect(provider!).instanceOf(LaunchJsonCodeActionProvider); }); diff --git a/extensions/positron-python/src/test/providers/repl.unit.test.ts b/extensions/positron-python/src/test/providers/repl.unit.test.ts index b4c4beb3c22..87811e243bf 100644 --- a/extensions/positron-python/src/test/providers/repl.unit.test.ts +++ b/extensions/positron-python/src/test/providers/repl.unit.test.ts @@ -43,7 +43,7 @@ suite('REPL Provider', () => { interpreterService = TypeMoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: 'ps' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: 'ps' } as unknown) as PythonEnvironment)); serviceContainer.setup((c) => c.get(IInterpreterService)).returns(() => interpreterService.object); }); teardown(() => { diff --git a/extensions/positron-python/src/test/pythonEnvironments/base/info/environmentInfoService.functional.test.ts b/extensions/positron-python/src/test/pythonEnvironments/base/info/environmentInfoService.functional.test.ts index d7ce4182b53..785148f8589 100644 --- a/extensions/positron-python/src/test/pythonEnvironments/base/info/environmentInfoService.functional.test.ts +++ b/extensions/positron-python/src/test/pythonEnvironments/base/info/environmentInfoService.functional.test.ts @@ -45,7 +45,8 @@ suite('Environment Info Service', () => { stubShellExec.returns( new Promise>((resolve) => { resolve({ - stdout: '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', + stdout: + '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', stderr: 'Some std error', // This should be ignored. }); }), diff --git a/extensions/positron-python/src/test/pythonEnvironments/base/locatorUtils.unit.test.ts b/extensions/positron-python/src/test/pythonEnvironments/base/locatorUtils.unit.test.ts index c726c7f7c52..8e4bc02e479 100644 --- a/extensions/positron-python/src/test/pythonEnvironments/base/locatorUtils.unit.test.ts +++ b/extensions/positron-python/src/test/pythonEnvironments/base/locatorUtils.unit.test.ts @@ -87,16 +87,14 @@ suite('Python envs locator utils - getQueryFilter', () => { assert.deepEqual(filtered, []); }); - ( - [ - [PythonEnvKind.Unknown, [env3]], - [PythonEnvKind.System, [env1, env5]], - [PythonEnvKind.MicrosoftStore, []], - [PythonEnvKind.Pyenv, [env2, env4]], - [PythonEnvKind.Venv, [envL1, envSL1, envSL5]], - [PythonEnvKind.Conda, [env6, envL2, envSL3]], - ] as [PythonEnvKind, PythonEnvInfo[]][] - ).forEach(([kind, expected]) => { + ([ + [PythonEnvKind.Unknown, [env3]], + [PythonEnvKind.System, [env1, env5]], + [PythonEnvKind.MicrosoftStore, []], + [PythonEnvKind.Pyenv, [env2, env4]], + [PythonEnvKind.Venv, [envL1, envSL1, envSL5]], + [PythonEnvKind.Conda, [env6, envL2, envSL3]], + ] as [PythonEnvKind, PythonEnvInfo[]][]).forEach(([kind, expected]) => { test(`match some (one kind: ${kind})`, () => { const query: PythonLocatorQuery = { kinds: [kind] }; diff --git a/extensions/positron-python/src/test/pythonEnvironments/base/locators/composite/envsResolver.unit.test.ts b/extensions/positron-python/src/test/pythonEnvironments/base/locators/composite/envsResolver.unit.test.ts index 64afb97a995..5cda8a1cf73 100644 --- a/extensions/positron-python/src/test/pythonEnvironments/base/locators/composite/envsResolver.unit.test.ts +++ b/extensions/positron-python/src/test/pythonEnvironments/base/locators/composite/envsResolver.unit.test.ts @@ -116,7 +116,8 @@ suite('Python envs locator - Environments Resolver', () => { stubShellExec.returns( new Promise>((resolve) => { resolve({ - stdout: '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', + stdout: + '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', }); }), ); @@ -264,7 +265,8 @@ suite('Python envs locator - Environments Resolver', () => { () => new Promise>((resolve) => { resolve({ - stdout: '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', + stdout: + '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', }); }), ), @@ -357,7 +359,8 @@ suite('Python envs locator - Environments Resolver', () => { stubShellExec.returns( new Promise>((resolve) => { resolve({ - stdout: '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', + stdout: + '{"versionInfo": [3, 8, 3, "final", 0], "sysPrefix": "path", "sysVersion": "3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]", "is64Bit": true}', }); }), ); diff --git a/extensions/positron-python/src/test/pythonEnvironments/base/locators/lowLevel/watcherTestUtils.ts b/extensions/positron-python/src/test/pythonEnvironments/base/locators/lowLevel/watcherTestUtils.ts index adba35c4b47..6e269f5680b 100644 --- a/extensions/positron-python/src/test/pythonEnvironments/base/locators/lowLevel/watcherTestUtils.ts +++ b/extensions/positron-python/src/test/pythonEnvironments/base/locators/lowLevel/watcherTestUtils.ts @@ -24,10 +24,7 @@ import { run } from '../envTestUtils'; * tests, where we need to create environments. */ class Venvs { - constructor( - private readonly root: string, - private readonly prefix = '.virtualenv-', - ) {} + constructor(private readonly root: string, private readonly prefix = '.virtualenv-') {} public async create(name: string): Promise<{ executable: string; envDir: string }> { const envName = this.resolve(name); diff --git a/extensions/positron-python/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts b/extensions/positron-python/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts index 910f9b3a2bf..34d28d2b0f9 100644 --- a/extensions/positron-python/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts +++ b/extensions/positron-python/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts @@ -131,7 +131,7 @@ suite('Conda and its environments are located correctly', () => { if (typeof filePath !== 'string') { throw new Error(`expected filePath to be string, got ${typeof filePath}`); } - return Object.keys(getFile(filePath, 'throwIfMissing')) as unknown as fs.Dirent[]; + return (Object.keys(getFile(filePath, 'throwIfMissing')) as unknown) as fs.Dirent[]; }); sinon @@ -152,20 +152,22 @@ suite('Conda and its environments are located correctly', () => { return names; } - return names.map((name): fs.Dirent => { - const isFile = typeof dir[name] === 'string'; - return { - name, - path: dir.name?.toString() ?? '', - isFile: () => isFile, - isDirectory: () => !isFile, - isBlockDevice: () => false, - isCharacterDevice: () => false, - isSymbolicLink: () => false, - isFIFO: () => false, - isSocket: () => false, - }; - }); + return names.map( + (name): fs.Dirent => { + const isFile = typeof dir[name] === 'string'; + return { + name, + path: dir.name?.toString() ?? '', + isFile: () => isFile, + isDirectory: () => !isFile, + isBlockDevice: () => false, + isCharacterDevice: () => false, + isSymbolicLink: () => false, + isFIFO: () => false, + isSocket: () => false, + }; + }, + ); }); sinon diff --git a/extensions/positron-python/src/test/pythonEnvironments/creation/common/installCheckUtils.unit.test.ts b/extensions/positron-python/src/test/pythonEnvironments/creation/common/installCheckUtils.unit.test.ts index 9ff04069630..2ad1addbb1b 100644 --- a/extensions/positron-python/src/test/pythonEnvironments/creation/common/installCheckUtils.unit.test.ts +++ b/extensions/positron-python/src/test/pythonEnvironments/creation/common/installCheckUtils.unit.test.ts @@ -49,7 +49,7 @@ suite('Install check diagnostics tests', () => { interpreterService = typemoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(typemoq.It.isAny())) - .returns(() => Promise.resolve({ path: 'python' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: 'python' } as unknown) as PythonEnvironment)); getConfigurationStub = sinon.stub(workspaceApis, 'getConfiguration'); getConfigurationStub.callsFake((section?: string, _scope?: ConfigurationScope | null) => { if (section === 'python') { diff --git a/extensions/positron-python/src/test/pythonEnvironments/creation/globalPipInTerminalTrigger.unit.test.ts b/extensions/positron-python/src/test/pythonEnvironments/creation/globalPipInTerminalTrigger.unit.test.ts index d792670ae36..18bad59a394 100644 --- a/extensions/positron-python/src/test/pythonEnvironments/creation/globalPipInTerminalTrigger.unit.test.ts +++ b/extensions/positron-python/src/test/pythonEnvironments/creation/globalPipInTerminalTrigger.unit.test.ts @@ -79,7 +79,7 @@ suite('Global Pip in Terminal Trigger', () => { execEvent.setup((e) => e.shellIntegration).returns(() => shellIntegration.object); shellIntegration .setup((s) => s.executeCommand(typemoq.It.isAnyString())) - .returns(() => ({}) as unknown as TerminalShellExecution); + .returns(() => (({} as unknown) as TerminalShellExecution)); }); teardown(() => { @@ -132,7 +132,7 @@ suite('Global Pip in Terminal Trigger', () => { registerTriggerForPipInTerminal(disposables); shellIntegration.setup((s) => s.cwd).returns(() => outsideWorkspace); - await handler?.({ shellIntegration: shellIntegration.object } as unknown as TerminalShellExecutionStartEvent); + await handler?.(({ shellIntegration: shellIntegration.object } as unknown) as TerminalShellExecutionStartEvent); assert.strictEqual(disposables.length, 1); sinon.assert.calledOnce(shouldPromptToCreateEnvStub); @@ -151,7 +151,7 @@ suite('Global Pip in Terminal Trigger', () => { const disposables: Disposable[] = []; registerTriggerForPipInTerminal(disposables); - await handler?.({ shellIntegration: shellIntegration.object } as unknown as TerminalShellExecutionStartEvent); + await handler?.(({ shellIntegration: shellIntegration.object } as unknown) as TerminalShellExecutionStartEvent); assert.strictEqual(disposables.length, 1); sinon.assert.calledOnce(shouldPromptToCreateEnvStub); @@ -171,7 +171,7 @@ suite('Global Pip in Terminal Trigger', () => { registerTriggerForPipInTerminal(disposables); await handler?.({ - terminal: {} as unknown as Terminal, + terminal: ({} as unknown) as Terminal, shellIntegration: shellIntegration.object, execution: { cwd: workspace1.uri, @@ -205,7 +205,7 @@ suite('Global Pip in Terminal Trigger', () => { registerTriggerForPipInTerminal(disposables); await handler?.({ - terminal: {} as unknown as Terminal, + terminal: ({} as unknown) as Terminal, shellIntegration: shellIntegration.object, execution: { cwd: workspace1.uri, @@ -241,7 +241,7 @@ suite('Global Pip in Terminal Trigger', () => { registerTriggerForPipInTerminal(disposables); await handler?.({ - terminal: {} as unknown as Terminal, + terminal: ({} as unknown) as Terminal, shellIntegration: shellIntegration.object, execution: { cwd: workspace1.uri, @@ -281,7 +281,7 @@ suite('Global Pip in Terminal Trigger', () => { registerTriggerForPipInTerminal(disposables); await handler?.({ - terminal: {} as unknown as Terminal, + terminal: ({} as unknown) as Terminal, shellIntegration: shellIntegration.object, execution: { cwd: workspace1.uri, diff --git a/extensions/positron-python/src/test/startupTelemetry.unit.test.ts b/extensions/positron-python/src/test/startupTelemetry.unit.test.ts index 3ff0f32d628..a9af3adff9a 100644 --- a/extensions/positron-python/src/test/startupTelemetry.unit.test.ts +++ b/extensions/positron-python/src/test/startupTelemetry.unit.test.ts @@ -33,7 +33,7 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => { test(`Return false if using settings equals {globalValue: ${globalValue}, workspaceValue: ${workspaceValue}, workspaceFolderValue: ${workspaceFolderValue}}`, () => { interpreterPathService .setup((i) => i.inspect(resource)) - .returns(() => ({ globalValue, workspaceValue, workspaceFolderValue }) as any); + .returns(() => ({ globalValue, workspaceValue, workspaceFolderValue } as any)); const result = hasUserDefinedPythonPath(resource, serviceContainer.object); expect(result).to.equal(false, 'Should be false'); }); @@ -44,7 +44,7 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => { test('Return true if using setting value equals something else', () => { interpreterPathService .setup((i) => i.inspect(resource)) - .returns(() => ({ globalValue: 'something else' }) as any); + .returns(() => ({ globalValue: 'something else' } as any)); const result = hasUserDefinedPythonPath(resource, serviceContainer.object); expect(result).to.equal(true, 'Should be true'); }); diff --git a/extensions/positron-python/src/test/tensorBoard/tensorBoardSession.test.ts b/extensions/positron-python/src/test/tensorBoard/tensorBoardSession.test.ts index 92c6fcb9999..626740f4f53 100644 --- a/extensions/positron-python/src/test/tensorBoard/tensorBoardSession.test.ts +++ b/extensions/positron-python/src/test/tensorBoard/tensorBoardSession.test.ts @@ -485,7 +485,7 @@ suite('TensorBoard session creation', async () => { return [showQuickPickStub, createInputStub, filePickerStub]; } test('Resolves filepaths without displaying prompt', async () => { - const session = (await createSession()) as unknown as ITensorBoardSessionTestAPI; + const session = ((await createSession()) as unknown) as ITensorBoardSessionTestAPI; const stubs = setupStubsForMultiStepInput(); await session.jumpToSource(fsPath, 0); assert.ok(window.activeTextEditor !== undefined, 'Source file not resolved'); @@ -496,7 +496,7 @@ suite('TensorBoard session creation', async () => { ); }); test('Display quickpick to user if filepath is not on disk', async () => { - const session = (await createSession()) as unknown as ITensorBoardSessionTestAPI; + const session = ((await createSession()) as unknown) as ITensorBoardSessionTestAPI; const stubs = setupStubsForMultiStepInput(); await session.jumpToSource('/nonexistent/file/path.py', 0); assert.ok(window.activeTextEditor !== undefined, 'Source file not resolved'); diff --git a/extensions/positron-python/src/test/terminals/activation.unit.test.ts b/extensions/positron-python/src/test/terminals/activation.unit.test.ts index 97898e7da6b..dea0c891229 100644 --- a/extensions/positron-python/src/test/terminals/activation.unit.test.ts +++ b/extensions/positron-python/src/test/terminals/activation.unit.test.ts @@ -37,7 +37,7 @@ suite('Terminal', () => { instance(resourceService), ); - terminal = { + terminal = ({ dispose: noop, hide: noop, name: 'Some Name', @@ -46,8 +46,8 @@ suite('Terminal', () => { sendText: noop, show: noop, exitStatus: { code: 0 }, - } as unknown as Terminal; - nonActivatedTerminal = { + } as unknown) as Terminal; + nonActivatedTerminal = ({ dispose: noop, hide: noop, creationOptions: { hideFromUser: true }, @@ -56,7 +56,7 @@ suite('Terminal', () => { sendText: noop, show: noop, exitStatus: { code: 0 }, - } as unknown as Terminal; + } as unknown) as Terminal; autoActivation.register(); }); // teardown(() => fakeTimer.uninstall()); @@ -64,7 +64,7 @@ suite('Terminal', () => { test('Should activate terminal', async () => { // Trigger opening a terminal. - await (onDidOpenTerminalEventEmitter.fire(terminal) as unknown as Promise); + await ((onDidOpenTerminalEventEmitter.fire(terminal) as unknown) as Promise); // The terminal should get activated. verify(activator.activateEnvironmentInTerminal(terminal, anything())).once(); @@ -72,7 +72,7 @@ suite('Terminal', () => { test('Should not activate terminal if name starts with specific prefix', async () => { // Trigger opening a terminal. - await (onDidOpenTerminalEventEmitter.fire(nonActivatedTerminal) as unknown as Promise); + await ((onDidOpenTerminalEventEmitter.fire(nonActivatedTerminal) as unknown) as Promise); // The terminal should get activated. verify(activator.activateEnvironmentInTerminal(anything(), anything())).never(); diff --git a/extensions/positron-python/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts b/extensions/positron-python/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts index 57ada697d71..55eb51d1c31 100644 --- a/extensions/positron-python/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts +++ b/extensions/positron-python/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts @@ -45,7 +45,7 @@ suite('Terminal - Code Execution Manager', () => { interpreterService = TypeMoq.Mock.ofType(); interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: 'ps' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: 'ps' } as unknown) as PythonEnvironment)); serviceContainer.setup((c) => c.get(IInterpreterService)).returns(() => interpreterService.object); executionManager = new CodeExecutionManager( commandManager.object, diff --git a/extensions/positron-python/src/test/terminals/codeExecution/djangoShellCodeExect.unit.test.ts b/extensions/positron-python/src/test/terminals/codeExecution/djangoShellCodeExect.unit.test.ts index 6e823c7c489..749d9467276 100644 --- a/extensions/positron-python/src/test/terminals/codeExecution/djangoShellCodeExect.unit.test.ts +++ b/extensions/positron-python/src/test/terminals/codeExecution/djangoShellCodeExect.unit.test.ts @@ -100,7 +100,7 @@ suite('Terminal - Django Shell Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => isWindows); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); const replCommandArgs = await (executor as DjangoShellCodeExecutionProvider).getExecutableInfo(resource); @@ -221,7 +221,7 @@ suite('Terminal - Django Shell Code Execution', () => { ) { interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); const condaFile = 'conda'; diff --git a/extensions/positron-python/src/test/terminals/codeExecution/helper.test.ts b/extensions/positron-python/src/test/terminals/codeExecution/helper.test.ts index c3e6b9f55e2..2ea00e77c92 100644 --- a/extensions/positron-python/src/test/terminals/codeExecution/helper.test.ts +++ b/extensions/positron-python/src/test/terminals/codeExecution/helper.test.ts @@ -135,7 +135,7 @@ suite('Terminal - Code Execution Helper', () => { .setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())) .returns((_, args: string[]) => { execArgs = args.join(' '); - return {} as unknown as ObservableExecutionResult; + return ({} as unknown) as ObservableExecutionResult; }); await helper.normalizeLines('print("hello")'); diff --git a/extensions/positron-python/src/test/terminals/codeExecution/terminalCodeExec.unit.test.ts b/extensions/positron-python/src/test/terminals/codeExecution/terminalCodeExec.unit.test.ts index 9b097c25ca9..4f60adb3b93 100644 --- a/extensions/positron-python/src/test/terminals/codeExecution/terminalCodeExec.unit.test.ts +++ b/extensions/positron-python/src/test/terminals/codeExecution/terminalCodeExec.unit.test.ts @@ -161,7 +161,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isLinux).returns(() => isLinux); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: PYTHON_PATH } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: PYTHON_PATH } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => []); await executor.initializeRepl(); @@ -196,7 +196,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => true); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: PYTHON_PATH } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: PYTHON_PATH } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => []); await executor.executeFile(file); @@ -223,7 +223,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => true); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: PYTHON_PATH } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: PYTHON_PATH } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => []); await executor.executeFile(file); @@ -241,7 +241,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => false); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: PYTHON_PATH } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: PYTHON_PATH } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => []); await executor.executeFile(file); @@ -269,7 +269,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => isWindows); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: PYTHON_PATH } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: PYTHON_PATH } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => []); await executor.executeFile(file); @@ -297,7 +297,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => isWindows); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: PYTHON_PATH } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: PYTHON_PATH } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => []); await executor.executeFile(file); @@ -320,7 +320,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => isWindows); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: PYTHON_PATH } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: PYTHON_PATH } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => []); await executor.executeFile(file); @@ -343,7 +343,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => isWindows); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); terminalSettings.setup((t) => t.executeInFileDir).returns(() => false); workspace.setup((w) => w.getWorkspaceFolder(TypeMoq.It.isAny())).returns(() => undefined); @@ -389,7 +389,7 @@ suite('Terminal - Code Execution', () => { ): Promise { interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); terminalSettings.setup((t) => t.executeInFileDir).returns(() => false); workspace.setup((w) => w.getWorkspaceFolder(TypeMoq.It.isAny())).returns(() => undefined); @@ -459,7 +459,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => isWindows); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); const expectedTerminalArgs = isDjangoRepl ? terminalArgs.concat(['manage.py', 'shell']) : terminalArgs; @@ -511,7 +511,7 @@ suite('Terminal - Code Execution', () => { ) { interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); const condaFile = 'conda'; @@ -569,7 +569,7 @@ suite('Terminal - Code Execution', () => { await executor.execute(''); await executor.execute(' '); - await executor.execute(undefined as any as string); + await executor.execute((undefined as any) as string); terminalService.verify( async (t) => t.sendCommand(TypeMoq.It.isAny(), TypeMoq.It.isAny()), @@ -585,7 +585,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => false); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); await executor.execute('cmd1'); @@ -606,7 +606,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => false); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); await executor.execute('cmd1'); @@ -639,7 +639,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => false); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); await executor.execute('cmd1'); @@ -664,7 +664,7 @@ suite('Terminal - Code Execution', () => { platform.setup((p) => p.isWindows).returns(() => false); interpreterService .setup((s) => s.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: pythonPath } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: pythonPath } as unknown) as PythonEnvironment)); terminalSettings.setup((t) => t.launchArgs).returns(() => terminalArgs); await executor.execute('cmd1', resource); diff --git a/extensions/positron-python/src/test/terminals/serviceRegistry.unit.test.ts b/extensions/positron-python/src/test/terminals/serviceRegistry.unit.test.ts index 61a8608da77..403ddf4f322 100644 --- a/extensions/positron-python/src/test/terminals/serviceRegistry.unit.test.ts +++ b/extensions/positron-python/src/test/terminals/serviceRegistry.unit.test.ts @@ -62,7 +62,7 @@ suite('Terminal - Service Registry', () => { typemoq.It.is((v) => args[0] === v), typemoq.It.is((value) => args[1] === value), - typemoq.It.isValue(args[2] as unknown as string), + typemoq.It.isValue((args[2] as unknown) as string), ), ) .verifiable(typemoq.Times.once()); diff --git a/extensions/positron-python/src/test/testBootstrap.ts b/extensions/positron-python/src/test/testBootstrap.ts index 2e5ba8d0712..03f24a680d0 100644 --- a/extensions/positron-python/src/test/testBootstrap.ts +++ b/extensions/positron-python/src/test/testBootstrap.ts @@ -88,13 +88,16 @@ async function startSocketServer() { }); }); - server.listen({ host: '127.0.0.1', port: 0 }, async (): Promise => { - const port = (server!.address() as AddressInfo).port; - console.log(`Test server listening on port ${port}`); - await deletePortFile(); - await fs.writeFile(portFile, port.toString()); - resolve(); - }); + server.listen( + { host: '127.0.0.1', port: 0 }, + async (): Promise => { + const port = (server!.address() as AddressInfo).port; + console.log(`Test server listening on port ${port}`); + await deletePortFile(); + await fs.writeFile(portFile, port.toString()); + resolve(); + }, + ); server.on('error', (ex) => { // Just log it, no need to do anything else. console.error(ex); diff --git a/extensions/positron-python/src/test/testing/common/debugLauncher.unit.test.ts b/extensions/positron-python/src/test/testing/common/debugLauncher.unit.test.ts index 1e60be82ca8..ef3e678c13f 100644 --- a/extensions/positron-python/src/test/testing/common/debugLauncher.unit.test.ts +++ b/extensions/positron-python/src/test/testing/common/debugLauncher.unit.test.ts @@ -115,7 +115,7 @@ suite('Unit Tests - Debug Launcher', () => { ) { interpreterService .setup((i) => i.getActiveInterpreter(TypeMoq.It.isAny())) - .returns(() => Promise.resolve({ path: 'python' } as unknown as PythonEnvironment)); + .returns(() => Promise.resolve(({ path: 'python' } as unknown) as PythonEnvironment)); settings.setup((p) => p.envFile).returns(() => __filename); const args = expected.args; const debugArgs = testProvider === 'unittest' ? args.filter((item: string) => item !== '--debug') : args; diff --git a/extensions/positron-python/src/test/testing/common/testingAdapter.test.ts b/extensions/positron-python/src/test/testing/common/testingAdapter.test.ts index eb827e26eae..c01fed29bac 100644 --- a/extensions/positron-python/src/test/testing/common/testingAdapter.test.ts +++ b/extensions/positron-python/src/test/testing/common/testingAdapter.test.ts @@ -341,13 +341,11 @@ suite('End to End Tests: test adapters', () => { traceLog('windows machine detected, converting path to lowercase for comparison'); const a = actualData.cwd.toLowerCase(); const b = filePath.toLowerCase(); - const testSimpleActual = ( - actualData.tests as { - children: { - path: string; - }[]; - } - ).children[0].path.toLowerCase(); + const testSimpleActual = (actualData.tests as { + children: { + path: string; + }[]; + }).children[0].path.toLowerCase(); const testSimpleExpected = filePath.toLowerCase(); assert.strictEqual(a, b, `Expected cwd to be the symlink path actual: ${a} expected: ${b}`); assert.strictEqual( @@ -362,13 +360,11 @@ suite('End to End Tests: test adapters', () => { 'Expected cwd to be the symlink path, check for non-windows machines', ); assert.strictEqual( - ( - actualData.tests as { - children: { - path: string; - }[]; - } - ).children[0].path, + (actualData.tests as { + children: { + path: string; + }[]; + }).children[0].path, filePath, 'Expected test path to be the symlink path, check for non windows machines', ); @@ -434,13 +430,11 @@ suite('End to End Tests: test adapters', () => { traceLog('windows machine detected, converting path to lowercase for comparison'); const a = actualData.cwd.toLowerCase(); const b = rootPathDiscoverySymlink.toLowerCase(); - const testSimpleActual = ( - actualData.tests as { - children: { - path: string; - }[]; - } - ).children[0].path.toLowerCase(); + const testSimpleActual = (actualData.tests as { + children: { + path: string; + }[]; + }).children[0].path.toLowerCase(); const testSimpleExpected = testSimpleSymlinkPath.toLowerCase(); assert.strictEqual(a, b, `Expected cwd to be the symlink path actual: ${a} expected: ${b}`); assert.strictEqual( @@ -455,13 +449,11 @@ suite('End to End Tests: test adapters', () => { 'Expected cwd to be the symlink path, check for non-windows machines', ); assert.strictEqual( - ( - actualData.tests as { - children: { - path: string; - }[]; - } - ).children[0].path, + (actualData.tests as { + children: { + path: string; + }[]; + }).children[0].path, testSimpleSymlinkPath, 'Expected test path to be the symlink path, check for non windows machines', ); @@ -555,7 +547,7 @@ suite('End to End Tests: test adapters', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); let collectedOutput = ''; testRun @@ -635,7 +627,7 @@ suite('End to End Tests: test adapters', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); let collectedOutput = ''; testRun @@ -710,7 +702,7 @@ suite('End to End Tests: test adapters', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); let collectedOutput = ''; testRun @@ -807,7 +799,7 @@ suite('End to End Tests: test adapters', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); let collectedOutput = ''; testRun @@ -879,7 +871,7 @@ suite('End to End Tests: test adapters', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); await discoveryAdapter.discoverTests(workspaceUri, pythonExecFactory).finally(() => { assert.strictEqual(callCount, 1, 'Expected _resolveDiscovery to be called once'); @@ -1013,7 +1005,7 @@ suite('End to End Tests: test adapters', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); await executionAdapter.runTests(workspaceUri, testIds, false, testRun.object, pythonExecFactory).finally(() => { assert.strictEqual(callCount, 1, 'Expected _resolveExecution to be called once'); @@ -1074,7 +1066,7 @@ suite('End to End Tests: test adapters', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); await executionAdapter.runTests(workspaceUri, testIds, false, testRun.object, pythonExecFactory).finally(() => { assert.strictEqual(callCount, 1, 'Expected _resolveExecution to be called once'); diff --git a/extensions/positron-python/src/test/testing/configuration.unit.test.ts b/extensions/positron-python/src/test/testing/configuration.unit.test.ts index 8298d236e38..abb57aac230 100644 --- a/extensions/positron-python/src/test/testing/configuration.unit.test.ts +++ b/extensions/positron-python/src/test/testing/configuration.unit.test.ts @@ -489,7 +489,7 @@ suite('Unit Tests - ConfigurationService', () => { .setup((c) => c.enable()) .returns(() => Promise.resolve()) .verifiable(typeMoq.Times.once()); - const configManagersToVerify: (typeof configMgr)[] = [configMgr]; + const configManagersToVerify: typeof configMgr[] = [configMgr]; await testConfigService.target.promptToEnableAndConfigureTestFramework(workspaceUri); diff --git a/extensions/positron-python/src/test/testing/testController/pytest/pytestDiscoveryAdapter.unit.test.ts b/extensions/positron-python/src/test/testing/testController/pytest/pytestDiscoveryAdapter.unit.test.ts index 7d2086980ab..d1587f59bd2 100644 --- a/extensions/positron-python/src/test/testing/testController/pytest/pytestDiscoveryAdapter.unit.test.ts +++ b/extensions/positron-python/src/test/testing/testController/pytest/pytestDiscoveryAdapter.unit.test.ts @@ -60,16 +60,16 @@ suite('pytest test discovery adapter', () => { }; // set up config service - configService = { + configService = ({ getSettings: () => ({ testing: { pytestArgs: ['.'] }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; // set up exec service with child process mockProc = new MockChildProcess('', ['']); execService = typeMoq.Mock.ofType(); - execService.setup((p) => (p as unknown as any).then).returns(() => undefined); + execService.setup((p) => ((p as unknown) as any).then).returns(() => undefined); outputChannel = typeMoq.Mock.ofType(); const output = new Observable>(() => { @@ -108,7 +108,7 @@ suite('pytest test discovery adapter', () => { ({ isFile: () => true, isSymbolicLink: () => false, - }) as fs.Stats, + } as fs.Stats), ); sinon.stub(fs.promises, 'realpath').callsFake(async (pathEntered) => pathEntered.toString()); @@ -142,21 +142,21 @@ suite('pytest test discovery adapter', () => { test('Test discovery correctly pulls pytest args from config service settings', async () => { // set up a config service with different pytest args const expectedPathNew = path.join('other', 'path'); - const configServiceNew: IConfigurationService = { + const configServiceNew: IConfigurationService = ({ getSettings: () => ({ testing: { pytestArgs: ['.', 'abc', 'xyz'], cwd: expectedPathNew, }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; sinon.stub(fs.promises, 'lstat').callsFake( async () => ({ isFile: () => true, isSymbolicLink: () => false, - }) as fs.Stats, + } as fs.Stats), ); sinon.stub(fs.promises, 'realpath').callsFake(async (pathEntered) => pathEntered.toString()); @@ -200,19 +200,19 @@ suite('pytest test discovery adapter', () => { ({ isFile: () => true, isSymbolicLink: () => true, - }) as fs.Stats, + } as fs.Stats), ); sinon.stub(fs.promises, 'realpath').callsFake(async (pathEntered) => pathEntered.toString()); // set up a config service with different pytest args - const configServiceNew: IConfigurationService = { + const configServiceNew: IConfigurationService = ({ getSettings: () => ({ testing: { pytestArgs: ['.', 'abc', 'xyz'], cwd: expectedPath, }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; // set up exec mock deferred = createDeferred(); @@ -267,20 +267,20 @@ suite('pytest test discovery adapter', () => { counter = counter + 1; return counter > 2; }, - }) as fs.Stats, + } as fs.Stats), ); sinon.stub(fs.promises, 'realpath').callsFake(async () => 'diff value'); // set up a config service with different pytest args - const configServiceNew: IConfigurationService = { + const configServiceNew: IConfigurationService = ({ getSettings: () => ({ testing: { pytestArgs: ['.', 'abc', 'xyz'], cwd: expectedPath, }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; // set up exec mock deferred = createDeferred(); diff --git a/extensions/positron-python/src/test/testing/testController/pytest/pytestExecutionAdapter.unit.test.ts b/extensions/positron-python/src/test/testing/testController/pytest/pytestExecutionAdapter.unit.test.ts index 580010ec612..b82a663cf86 100644 --- a/extensions/positron-python/src/test/testing/testController/pytest/pytestExecutionAdapter.unit.test.ts +++ b/extensions/positron-python/src/test/testing/testController/pytest/pytestExecutionAdapter.unit.test.ts @@ -36,12 +36,12 @@ suite('pytest test execution adapter', () => { let utilsStartTestIdsNamedPipeStub: sinon.SinonStub; let utilsStartRunResultNamedPipeStub: sinon.SinonStub; setup(() => { - configService = { + configService = ({ getSettings: () => ({ testing: { pytestArgs: ['.'] }, }), isTestExecution: () => false, - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; // set up exec service with child process mockProc = new MockChildProcess('', ['']); @@ -77,9 +77,9 @@ suite('pytest test execution adapter', () => { deferred.resolve(); return Promise.resolve({ stdout: '{}' }); }); - execFactory.setup((p) => (p as unknown as any).then).returns(() => undefined); - execService.setup((p) => (p as unknown as any).then).returns(() => undefined); - debugLauncher.setup((p) => (p as unknown as any).then).returns(() => undefined); + execFactory.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + execService.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + debugLauncher.setup((p) => ((p as unknown) as any).then).returns(() => undefined); myTestPath = path.join('/', 'my', 'test', 'path', '/'); utilsStartRunResultNamedPipeStub = sinon.stub(util, 'startRunResultNamedPipe'); @@ -115,7 +115,7 @@ suite('pytest test execution adapter', () => { }); }); const testRun = typeMoq.Mock.ofType(); - testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined }) as any); + testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined } as any)); const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); adapter = new PytestTestExecutionAdapter(configService, outputChannel.object); @@ -146,7 +146,7 @@ suite('pytest test execution adapter', () => { return Promise.resolve('testIdPipe-mockName'); }); const testRun = typeMoq.Mock.ofType(); - testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined }) as any); + testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined } as any)); const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); adapter = new PytestTestExecutionAdapter(configService, outputChannel.object); @@ -197,14 +197,14 @@ suite('pytest test execution adapter', () => { return Promise.resolve('testIdPipe-mockName'); }); const testRun = typeMoq.Mock.ofType(); - testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined }) as any); + testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined } as any)); const newCwd = path.join('new', 'path'); - configService = { + configService = ({ getSettings: () => ({ testing: { pytestArgs: ['.'], cwd: newCwd }, }), isTestExecution: () => false, - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); adapter = new PytestTestExecutionAdapter(configService, outputChannel.object); @@ -262,7 +262,7 @@ suite('pytest test execution adapter', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); diff --git a/extensions/positron-python/src/test/testing/testController/resultResolver.unit.test.ts b/extensions/positron-python/src/test/testing/testController/resultResolver.unit.test.ts index 3ed3d1b251b..5ecf75987b3 100644 --- a/extensions/positron-python/src/test/testing/testController/resultResolver.unit.test.ts +++ b/extensions/positron-python/src/test/testing/testController/resultResolver.unit.test.ts @@ -29,7 +29,7 @@ suite('Result Resolver tests', () => { let cancelationToken: CancellationToken; setup(() => { - testController = { + testController = ({ items: { get: () => { log.push('get'); @@ -48,9 +48,9 @@ suite('Result Resolver tests', () => { dispose: () => { // empty }, - } as unknown as TestController; + } as unknown) as TestController; defaultErrorMessage = 'pytest test discovery error (see Output > Python)'; - blankTestItem = { + blankTestItem = ({ canResolveChildren: false, tags: [], children: { @@ -58,10 +58,10 @@ suite('Result Resolver tests', () => { // empty }, }, - } as unknown as TestItem; - cancelationToken = { + } as unknown) as TestItem; + cancelationToken = ({ isCancellationRequested: false, - } as unknown as CancellationToken; + } as unknown) as CancellationToken; }); teardown(() => { sinon.restore(); @@ -299,9 +299,9 @@ suite('Result Resolver tests', () => { testControllerMock = typemoq.Mock.ofType(); testControllerMock.setup((t) => t.items).returns(() => testItemCollectionMock.object); - cancelationToken = { + cancelationToken = ({ isCancellationRequested: false, - } as unknown as CancellationToken; + } as unknown) as CancellationToken; // define functions within runInstance runInstance = typemoq.Mock.ofType(); @@ -356,7 +356,7 @@ suite('Result Resolver tests', () => { generatedId = id; traceLog('createTestItem function called with id:', id); }) - .returns(() => ({ id: 'id_this', label: 'label_this', uri: workspaceUri }) as TestItem); + .returns(() => ({ id: 'id_this', label: 'label_this', uri: workspaceUri } as TestItem)); // create a successful payload with a single test called mockTestItem1 const successPayload: ExecutionTestPayload = { @@ -572,7 +572,7 @@ suite('Result Resolver tests', () => { function createMockTestItem(id: string): TestItem { const range = new Range(0, 0, 0, 0); - const mockTestItem = { + const mockTestItem = ({ id, canResolveChildren: false, tags: [], @@ -583,7 +583,7 @@ function createMockTestItem(id: string): TestItem { }, range, uri: Uri.file('/foo/bar'), - } as unknown as TestItem; + } as unknown) as TestItem; return mockTestItem; } diff --git a/extensions/positron-python/src/test/testing/testController/testCancellationRunAdapters.unit.test.ts b/extensions/positron-python/src/test/testing/testController/testCancellationRunAdapters.unit.test.ts index dfd99b31ec9..bddf057d4f0 100644 --- a/extensions/positron-python/src/test/testing/testController/testCancellationRunAdapters.unit.test.ts +++ b/extensions/positron-python/src/test/testing/testController/testCancellationRunAdapters.unit.test.ts @@ -35,12 +35,12 @@ suite('Execution Flow Run Adapters', () => { setup(() => { // general vars myTestPath = path.join('/', 'my', 'test', 'path', '/'); - configService = { + configService = ({ getSettings: () => ({ testing: { pytestArgs: ['.'], unittestArgs: ['-v', '-s', '.', '-p', 'test*'] }, }), isTestExecution: () => false, - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; // set up execService and execFactory, all mocked execServiceStub = typeMoq.Mock.ofType(); @@ -53,7 +53,7 @@ suite('Execution Flow Run Adapters', () => { // debug specific mocks debugLauncher = typeMoq.Mock.ofType(); - debugLauncher.setup((p) => (p as unknown as any).then).returns(() => undefined); + debugLauncher.setup((p) => ((p as unknown) as any).then).returns(() => undefined); }); teardown(() => { sinon.restore(); @@ -82,8 +82,8 @@ suite('Execution Flow Run Adapters', () => { execFactoryStub .setup((x) => x.createActivatedEnvironment(typeMoq.It.isAny())) .returns(() => Promise.resolve(execServiceStub.object)); - execFactoryStub.setup((p) => (p as unknown as any).then).returns(() => undefined); - execServiceStub.setup((p) => (p as unknown as any).then).returns(() => undefined); + execFactoryStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + execServiceStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); // test ids named pipe mocking const deferredStartTestIdsNamedPipe = createDeferred(); @@ -160,8 +160,8 @@ suite('Execution Flow Run Adapters', () => { execFactoryStub .setup((x) => x.createActivatedEnvironment(typeMoq.It.isAny())) .returns(() => Promise.resolve(execServiceStub.object)); - execFactoryStub.setup((p) => (p as unknown as any).then).returns(() => undefined); - execServiceStub.setup((p) => (p as unknown as any).then).returns(() => undefined); + execFactoryStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + execServiceStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); // test ids named pipe mocking const deferredStartTestIdsNamedPipe = createDeferred(); diff --git a/extensions/positron-python/src/test/testing/testController/unittest/testDiscoveryAdapter.unit.test.ts b/extensions/positron-python/src/test/testing/testController/unittest/testDiscoveryAdapter.unit.test.ts index dfde4ac3fcc..7c700fdd4ec 100644 --- a/extensions/positron-python/src/test/testing/testController/unittest/testDiscoveryAdapter.unit.test.ts +++ b/extensions/positron-python/src/test/testing/testController/unittest/testDiscoveryAdapter.unit.test.ts @@ -35,11 +35,11 @@ suite('Unittest test discovery adapter', () => { setup(() => { expectedPath = path.join('/', 'new', 'cwd'); - stubConfigSettings = { + stubConfigSettings = ({ getSettings: () => ({ testing: { unittestArgs: ['-v', '-s', '.', '-p', 'test*'] }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; outputChannel = typemoq.Mock.ofType(); // set up exec service with child process @@ -66,8 +66,8 @@ suite('Unittest test discovery adapter', () => { execFactory .setup((x) => x.createActivatedEnvironment(typemoq.It.isAny())) .returns(() => Promise.resolve(execService.object)); - execFactory.setup((p) => (p as unknown as any).then).returns(() => undefined); - execService.setup((p) => (p as unknown as any).then).returns(() => undefined); + execFactory.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + execService.setup((p) => ((p as unknown) as any).then).returns(() => undefined); // constants expectedPath = path.join('/', 'my', 'test', 'path'); @@ -129,11 +129,11 @@ suite('Unittest test discovery adapter', () => { }); test('DiscoverTests should respect settings.testings.cwd when present', async () => { const expectedNewPath = path.join('/', 'new', 'cwd'); - stubConfigSettings = { + stubConfigSettings = ({ getSettings: () => ({ testing: { unittestArgs: ['-v', '-s', '.', '-p', 'test*'], cwd: expectedNewPath.toString() }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; const adapter = new UnittestTestDiscoveryAdapter(stubConfigSettings, outputChannel.object); adapter.discoverTests(uri, execFactory.object); const script = path.join(EXTENSION_ROOT_DIR, 'python_files', 'unittestadapter', 'discovery.py'); diff --git a/extensions/positron-python/src/test/testing/testController/unittest/testExecutionAdapter.unit.test.ts b/extensions/positron-python/src/test/testing/testController/unittest/testExecutionAdapter.unit.test.ts index 7ebcc7759e8..6d4757eff8d 100644 --- a/extensions/positron-python/src/test/testing/testController/unittest/testExecutionAdapter.unit.test.ts +++ b/extensions/positron-python/src/test/testing/testController/unittest/testExecutionAdapter.unit.test.ts @@ -36,12 +36,12 @@ suite('Unittest test execution adapter', () => { let utilsStartTestIdsNamedPipeStub: sinon.SinonStub; let utilsStartRunResultNamedPipeStub: sinon.SinonStub; setup(() => { - configService = { + configService = ({ getSettings: () => ({ testing: { unittestArgs: ['.'] }, }), isTestExecution: () => false, - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; // set up exec service with child process mockProc = new MockChildProcess('', ['']); @@ -77,9 +77,9 @@ suite('Unittest test execution adapter', () => { deferred.resolve(); return Promise.resolve({ stdout: '{}' }); }); - execFactory.setup((p) => (p as unknown as any).then).returns(() => undefined); - execService.setup((p) => (p as unknown as any).then).returns(() => undefined); - debugLauncher.setup((p) => (p as unknown as any).then).returns(() => undefined); + execFactory.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + execService.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + debugLauncher.setup((p) => ((p as unknown) as any).then).returns(() => undefined); myTestPath = path.join('/', 'my', 'test', 'path', '/'); utilsStartRunResultNamedPipeStub = sinon.stub(util, 'startRunResultNamedPipe'); @@ -115,7 +115,7 @@ suite('Unittest test execution adapter', () => { }); }); const testRun = typeMoq.Mock.ofType(); - testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined }) as any); + testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined } as any)); const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); adapter = new UnittestTestExecutionAdapter(configService, outputChannel.object); @@ -146,7 +146,7 @@ suite('Unittest test execution adapter', () => { return Promise.resolve('testIdPipe-mockName'); }); const testRun = typeMoq.Mock.ofType(); - testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined }) as any); + testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined } as any)); const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); adapter = new UnittestTestExecutionAdapter(configService, outputChannel.object); @@ -196,14 +196,14 @@ suite('Unittest test execution adapter', () => { return Promise.resolve('testIdPipe-mockName'); }); const testRun = typeMoq.Mock.ofType(); - testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined }) as any); + testRun.setup((t) => t.token).returns(() => ({ onCancellationRequested: () => undefined } as any)); const newCwd = path.join('new', 'path'); - configService = { + configService = ({ getSettings: () => ({ testing: { unittestArgs: ['.'], cwd: newCwd }, }), isTestExecution: () => false, - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); adapter = new UnittestTestExecutionAdapter(configService, outputChannel.object); @@ -261,7 +261,7 @@ suite('Unittest test execution adapter', () => { () => ({ onCancellationRequested: () => undefined, - }) as any, + } as any), ); const uri = Uri.file(myTestPath); const outputChannel = typeMoq.Mock.ofType(); diff --git a/extensions/positron-python/src/test/testing/testController/workspaceTestAdapter.unit.test.ts b/extensions/positron-python/src/test/testing/testController/workspaceTestAdapter.unit.test.ts index 6549c4d21a1..9a07d4451e8 100644 --- a/extensions/positron-python/src/test/testing/testController/workspaceTestAdapter.unit.test.ts +++ b/extensions/positron-python/src/test/testing/testController/workspaceTestAdapter.unit.test.ts @@ -35,20 +35,20 @@ suite('Workspace test adapter', () => { let log: string[] = []; setup(() => { - stubConfigSettings = { + stubConfigSettings = ({ getSettings: () => ({ testing: { unittestArgs: ['--foo'] }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; - stubResultResolver = { + stubResultResolver = ({ resolveDiscovery: () => { // no body }, resolveExecution: () => { // no body }, - } as unknown as ITestResultResolver; + } as unknown) as ITestResultResolver; // const vsIdToRunIdGetStub = sinon.stub(stubResultResolver.vsIdToRunId, 'get'); // const expectedRunId = 'expectedRunId'; @@ -57,7 +57,7 @@ suite('Workspace test adapter', () => { // For some reason the 'tests' namespace in vscode returns undefined. // While I figure out how to expose to the tests, they will run // against a stub test controller and stub test items. - const testItem = { + const testItem = ({ canResolveChildren: false, tags: [], children: { @@ -65,9 +65,9 @@ suite('Workspace test adapter', () => { // empty }, }, - } as unknown as TestItem; + } as unknown) as TestItem; - testController = { + testController = ({ items: { get: () => { log.push('get'); @@ -89,7 +89,7 @@ suite('Workspace test adapter', () => { dispose: () => { // empty }, - } as unknown as TestController; + } as unknown) as TestController; // testController = tests.createTestController('mock-python-tests', 'Mock Python Tests'); @@ -130,7 +130,7 @@ suite('Workspace test adapter', () => { stubResultResolver, ); - const blankTestItem = { + const blankTestItem = ({ canResolveChildren: false, tags: [], children: { @@ -138,7 +138,7 @@ suite('Workspace test adapter', () => { // empty }, }, - } as unknown as TestItem; + } as unknown) as TestItem; const errorTestItemOptions: testItemUtilities.ErrorTestItemOptions = { id: 'id', label: 'label', @@ -267,13 +267,13 @@ suite('Workspace test adapter', () => { const sandbox = sinon.createSandbox(); setup(() => { - stubConfigSettings = { + stubConfigSettings = ({ getSettings: () => ({ testing: { unittestArgs: ['--foo'] }, }), - } as unknown as IConfigurationService; + } as unknown) as IConfigurationService; - stubResultResolver = { + stubResultResolver = ({ resolveDiscovery: () => { // no body }, @@ -283,8 +283,8 @@ suite('Workspace test adapter', () => { vsIdToRunId: { get: sinon.stub().returns('expectedRunId'), }, - } as unknown as ITestResultResolver; - const testItem = { + } as unknown) as ITestResultResolver; + const testItem = ({ canResolveChildren: false, tags: [], children: { @@ -292,9 +292,9 @@ suite('Workspace test adapter', () => { // empty }, }, - } as unknown as TestItem; + } as unknown) as TestItem; - testController = { + testController = ({ items: { get: () => { log.push('get'); @@ -316,7 +316,7 @@ suite('Workspace test adapter', () => { dispose: () => { // empty }, - } as unknown as TestController; + } as unknown) as TestController; const mockSendTelemetryEvent = ( eventName: EventName, @@ -453,7 +453,7 @@ suite('Workspace test adapter', () => { stubResultResolver, ); - const blankTestItem = { + const blankTestItem = ({ canResolveChildren: false, tags: [], children: { @@ -461,7 +461,7 @@ suite('Workspace test adapter', () => { // empty }, }, - } as unknown as TestItem; + } as unknown) as TestItem; const errorTestItemOptions: testItemUtilities.ErrorTestItemOptions = { id: 'id', label: 'label', @@ -501,7 +501,7 @@ suite('Workspace test adapter', () => { function createMockTestItem(id: string): TestItem { const range = typemoq.Mock.ofType(); - const mockTestItem = { + const mockTestItem = ({ id, canResolveChildren: false, tags: [], @@ -512,7 +512,7 @@ function createMockTestItem(id: string): TestItem { }, range, uri: Uri.file('/foo/bar'), - } as unknown as TestItem; + } as unknown) as TestItem; return mockTestItem; }