Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22,124 changes: 6,277 additions & 15,847 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/client/activation/node/analysisOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt

// eslint-disable-next-line class-methods-use-this
protected async getInitializationOptions(): Promise<LanguageClientOptions> {
return ({
return {
experimentationSupport: true,
trustedWorkspaceSupport: true,
} as unknown) as LanguageClientOptions;
} as unknown as LanguageClientOptions;
}
}
5 changes: 3 additions & 2 deletions src/client/activation/node/languageClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export class NodeLanguageClientFactory implements ILanguageClientFactory {
clientOptions: LanguageClientOptions,
): Promise<LanguageClient> {
// 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 : '';
Expand Down
4 changes: 1 addition & 3 deletions src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export function buildApi(
* * When no resource is provided, the setting scoped to the first workspace folder is returned.
* * If no folder is present, it returns the global setting.
*/
getExecutionDetails(
resource?: Resource,
): {
getExecutionDetails(resource?: Resource): {
/**
* E.g of execution commands returned could be,
* * `['<path to the interpreter set in settings>']`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ 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(
Expand Down
11 changes: 6 additions & 5 deletions src/client/chat/configurePythonEnvTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ import { CreateVirtualEnvTool } from './createVirtualEnvTool';
import { ISelectPythonEnvToolArguments, SelectPythonEnvTool } from './selectEnvTool';
import { BaseTool } from './baseTool';

export class ConfigurePythonEnvTool extends BaseTool<IResourceReference>
implements LanguageModelTool<IResourceReference> {
export class ConfigurePythonEnvTool
extends BaseTool<IResourceReference>
implements LanguageModelTool<IResourceReference>
{
private readonly terminalExecutionService: TerminalCodeExecutionProvider;
private readonly terminalHelper: ITerminalHelper;
private readonly recommendedEnvService: IRecommendedEnvironmentService;
Expand All @@ -46,9 +48,8 @@ export class ConfigurePythonEnvTool extends BaseTool<IResourceReference>
'standard',
);
this.terminalHelper = this.serviceContainer.get<ITerminalHelper>(ITerminalHelper);
this.recommendedEnvService = this.serviceContainer.get<IRecommendedEnvironmentService>(
IRecommendedEnvironmentService,
);
this.recommendedEnvService =
this.serviceContainer.get<IRecommendedEnvironmentService>(IRecommendedEnvironmentService);
}

async invokeImpl(
Expand Down
11 changes: 6 additions & 5 deletions src/client/chat/createVirtualEnvTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ interface ICreateVirtualEnvToolParams extends IResourceReference {
packageList?: string[]; // Added only becausewe have ability to create a virtual env with list of packages same tool within the in Python Env extension.
}

export class CreateVirtualEnvTool extends BaseTool<ICreateVirtualEnvToolParams>
implements LanguageModelTool<ICreateVirtualEnvToolParams> {
export class CreateVirtualEnvTool
extends BaseTool<ICreateVirtualEnvToolParams>
implements LanguageModelTool<ICreateVirtualEnvToolParams>
{
private readonly terminalExecutionService: TerminalCodeExecutionProvider;
private readonly terminalHelper: ITerminalHelper;
private readonly recommendedEnvService: IRecommendedEnvironmentService;
Expand All @@ -66,9 +68,8 @@ export class CreateVirtualEnvTool extends BaseTool<ICreateVirtualEnvToolParams>
'standard',
);
this.terminalHelper = this.serviceContainer.get<ITerminalHelper>(ITerminalHelper);
this.recommendedEnvService = this.serviceContainer.get<IRecommendedEnvironmentService>(
IRecommendedEnvironmentService,
);
this.recommendedEnvService =
this.serviceContainer.get<IRecommendedEnvironmentService>(IRecommendedEnvironmentService);
}

async invokeImpl(
Expand Down
6 changes: 4 additions & 2 deletions src/client/chat/getPythonEnvTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import { getEnvExtApi, useEnvExtension } from '../envExt/api.internal';
import { ErrorWithTelemetrySafeReason } from '../common/errors/errorUtils';
import { BaseTool } from './baseTool';

export class GetEnvironmentInfoTool extends BaseTool<IResourceReference>
implements LanguageModelTool<IResourceReference> {
export class GetEnvironmentInfoTool
extends BaseTool<IResourceReference>
implements LanguageModelTool<IResourceReference>
{
private readonly terminalExecutionService: TerminalCodeExecutionProvider;
private readonly pythonExecFactory: IPythonExecutionFactory;
private readonly processServiceFactory: IProcessServiceFactory;
Expand Down
6 changes: 4 additions & 2 deletions src/client/chat/installPackagesTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export interface IInstallPackageArgs extends IResourceReference {
packageList: string[];
}

export class InstallPackagesTool extends BaseTool<IInstallPackageArgs>
implements LanguageModelTool<IInstallPackageArgs> {
export class InstallPackagesTool
extends BaseTool<IInstallPackageArgs>
implements LanguageModelTool<IInstallPackageArgs>
{
public static readonly toolName = 'install_python_packages';
constructor(
private readonly api: PythonExtension['environments'],
Expand Down
6 changes: 4 additions & 2 deletions src/client/chat/selectEnvTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export interface ISelectPythonEnvToolArguments extends IResourceReference {
reason?: 'cancelled';
}

export class SelectPythonEnvTool extends BaseTool<ISelectPythonEnvToolArguments>
implements LanguageModelTool<ISelectPythonEnvToolArguments> {
export class SelectPythonEnvTool
extends BaseTool<ISelectPythonEnvToolArguments>
implements LanguageModelTool<ISelectPythonEnvToolArguments>
{
private readonly terminalExecutionService: TerminalCodeExecutionProvider;
private readonly terminalHelper: ITerminalHelper;
public static readonly toolName = 'selectEnvironment';
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/application/commandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<T | undefined> {
return commands.executeCommand<T>(command, ...rest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>;
const argSettingsDict = settings[property] as unknown as Record<string, unknown>;
if (typeof argSettingsDict === 'object') {
Object.keys(argSetting).forEach((item) => {
const prop = argSetting[item];
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/installer/channelManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class InstallationChannelManager implements IInstallationChannelManager {
installer,
};
});
const selection = await appShell.showQuickPick<typeof options[0]>(options, {
const selection = await appShell.showQuickPick<(typeof options)[0]>(options, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder,
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/process/currentProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/client/common/process/pythonExecutionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
public async create(options: ExecutionFactoryCreationOptions): Promise<IPythonExecutionService> {
let { pythonPath } = options;
if (!pythonPath || pythonPath === 'python') {
const activatedEnvLaunch = this.serviceContainer.get<IActivatedEnvironmentLaunch>(
IActivatedEnvironmentLaunch,
);
const activatedEnvLaunch =
this.serviceContainer.get<IActivatedEnvironmentLaunch>(IActivatedEnvironmentLaunch);
await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv();
// If python path wasn't passed in, we need to auto select it and then read it
// from the configuration.
Expand Down
17 changes: 9 additions & 8 deletions src/client/common/process/rawProcessApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ function getDefaultOptions<T extends ShellOptions | SpawnOptions>(options: T, de
const defaultOptions = { ...options };
const execOptions = defaultOptions as SpawnOptions;
if (execOptions) {
execOptions.encoding =
typeof execOptions.encoding === 'string' && execOptions.encoding.length > 0
? execOptions.encoding
: DEFAULT_ENCODING;
const { encoding } = execOptions;
delete execOptions.encoding;
execOptions.encoding = encoding;
// Handle encoding which can be string, null, or undefined from ExecOptions
const encoding = execOptions.encoding;
execOptions.encoding = typeof encoding === 'string' && encoding.length > 0 ? encoding : DEFAULT_ENCODING;
}
if (!defaultOptions.env || Object.keys(defaultOptions.env).length === 0) {
const env = defaultEnv || process.env;
Expand Down Expand Up @@ -58,7 +54,12 @@ export function shellExec(
const shellOptions = getDefaultOptions(options, defaultEnv);
if (!options.doNotLog) {
const processLogger = new ProcessLogger(new WorkspaceService());
processLogger.logProcess(command, undefined, shellOptions);
// Create compatible options for logging by ensuring encoding is not null
const logOptions: SpawnOptions = {
...shellOptions,
encoding: shellOptions.encoding || undefined,
};
processLogger.logProcess(command, undefined, logOptions);
}
return new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
8 changes: 4 additions & 4 deletions src/client/common/utils/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export interface IAsyncIterableIterator<T> extends IAsyncIterator<T>, AsyncItera
* An iterator that yields nothing.
*/
export function iterEmpty<T>(): IAsyncIterableIterator<T> {
return ((async function* () {
return (async function* () {
/** No body. */
})() as unknown) as IAsyncIterableIterator<T>;
})() as unknown as IAsyncIterableIterator<T>;
}

type NextResult<T> = { index: number } & (
Expand Down Expand Up @@ -279,12 +279,12 @@ export function raceTimeout<T>(timeout: number, defaultValue: T, ...promises: Pr
export function raceTimeout<T>(timeout: number, defaultValue: T, ...promises: Promise<T>[]): Promise<T> {
const resolveValue = isPromiseLike(defaultValue) ? undefined : defaultValue;
if (isPromiseLike(defaultValue)) {
promises.push((defaultValue as unknown) as Promise<T>);
promises.push(defaultValue as unknown as Promise<T>);
}

let promiseResolve: ((value: T) => void) | undefined = undefined;

const timer = setTimeout(() => promiseResolve?.((resolveValue as unknown) as T), timeout);
const timer = setTimeout(() => promiseResolve?.(resolveValue as unknown as T), timeout);

return Promise.race([
Promise.race(promises).finally(() => clearTimeout(timer)),
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/utils/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function getNames(e: any) {
}

export function getValues<T>(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)[] {
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/utils/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/utils/resourceLifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class DisposableStore implements IDisposable {
if (!o) {
return o;
}
if (((o as unknown) as DisposableStore) === this) {
if ((o as unknown as DisposableStore) === this) {
throw new Error('Cannot register a disposable on itself!');
}

Expand Down Expand Up @@ -191,7 +191,7 @@ export abstract class DisposableBase implements IDisposable {
* Adds `o` to the collection of disposables managed by this object.
*/
public _register<T extends IDisposable>(o: T): T {
if (((o as unknown) as DisposableBase) === this) {
if ((o as unknown as DisposableBase) === this) {
throw new Error('Cannot register a disposable on itself!');
}
return this._store.add(o);
Expand Down
10 changes: 5 additions & 5 deletions src/client/common/utils/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function copyStrict<T extends BasicVersionInfo>(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,
Expand Down Expand Up @@ -134,7 +134,7 @@ function validateVersionPart(prop: string, part: number, unnormalized?: ErrorMsg
* is responsible for any other properties beyond that.
*/
function validateBasicVersionInfo<T extends BasicVersionInfo>(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);
Expand Down Expand Up @@ -224,7 +224,7 @@ export function parseBasicVersionInfo<T extends BasicVersionInfo>(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 || '',
};
Expand Down Expand Up @@ -388,10 +388,10 @@ export function areSimilarVersions<T extends BasicVersionInfo, V extends BasicVe

if (result < 0) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return ((right as unknown) as any)[prop] === -1;
return (right as unknown as any)[prop] === -1;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return ((left as unknown) as any)[prop] === -1;
return (left as unknown as any)[prop] === -1;
}

// semver
Expand Down
12 changes: 5 additions & 7 deletions src/client/common/variables/systemVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,16 @@ export class SystemVariables extends AbstractSystemVariables {
}
this._execPath = process.execPath;
Object.keys(process.env).forEach((key) => {
((this as any) as Record<string, string | undefined>)[`env:${key}`] = ((this as any) as Record<
string,
string | undefined
>)[`env.${key}`] = process.env[key];
(this as any as Record<string, string | undefined>)[`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<string, string | undefined>)[`workspaceFolder:${basename}`] =
folder.uri.fsPath;
((this as any) as Record<string, string | undefined>)[`workspaceFolder:${folder.name}`] =
(this as any as Record<string, string | undefined>)[`workspaceFolder:${basename}`] = folder.uri.fsPath;
(this as any as Record<string, string | undefined>)[`workspaceFolder:${folder.name}`] =
folder.uri.fsPath;
});
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { getProgram } from './helper';

@injectable()
export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
implements IDebugConfigurationResolver<T> {
implements IDebugConfigurationResolver<T>
{
protected pythonPathSource: PythonPathSource = PythonPathSource.launchJson;

constructor(
Expand Down
4 changes: 1 addition & 3 deletions src/client/deprecatedProposedApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export interface DeprecatedProposedAPI {
* * When no resource is provided, the setting scoped to the first workspace folder is returned.
* * If no folder is present, it returns the global setting.
*/
getExecutionDetails(
resource?: Resource,
): Promise<{
getExecutionDetails(resource?: Resource): Promise<{
/**
* E.g of execution commands returned could be,
* * `['<path to the interpreter set in settings>']`
Expand Down
5 changes: 2 additions & 3 deletions src/client/envExt/api.internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ export function useEnvExtension(): boolean {
return _useExt;
}

const onDidChangeEnvironmentEnvExtEmitter: EventEmitter<DidChangeEnvironmentEventArgs> = new EventEmitter<
DidChangeEnvironmentEventArgs
>();
const onDidChangeEnvironmentEnvExtEmitter: EventEmitter<DidChangeEnvironmentEventArgs> =
new EventEmitter<DidChangeEnvironmentEventArgs>();
export function onDidChangeEnvironmentEnvExt(
listener: (e: DidChangeEnvironmentEventArgs) => unknown,
thisArgs?: unknown,
Expand Down
Loading
Loading