Skip to content

Commit

Permalink
Automated formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Positron Bot committed May 22, 2024
1 parent 235e9e9 commit 360d03b
Show file tree
Hide file tree
Showing 137 changed files with 919 additions and 959 deletions.
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@ 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,
_interpreter: PythonEnvironment | undefined,
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: 3 additions & 1 deletion extensions/positron-python/src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
* * `['<path to the interpreter set in settings>']`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down
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
5 changes: 1 addition & 4 deletions extensions/positron-python/src/client/common/contextKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
if (this.lastValue === value) {
Expand Down
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ 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
4 changes: 2 additions & 2 deletions extensions/positron-python/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
2 changes: 1 addition & 1 deletion extensions/positron-python/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
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
10 changes: 5 additions & 5 deletions extensions/positron-python/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
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,18 @@ 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 @@ -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`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
* * `['<path to the interpreter set in settings>']`
Expand Down
4 changes: 2 additions & 2 deletions extensions/positron-python/src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(IApplicationShell) as any as IAppShell;
appShell = (activatedServiceContainer.get<IApplicationShell>(IApplicationShell) as any) as IAppShell;
}
appShell.showErrorMessage(msg).ignoreErrors();
} catch (ex) {
Expand Down
15 changes: 9 additions & 6 deletions extensions/positron-python/src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ export async function activateComponents(
}

export function activateFeatures(ext: ExtensionState, _components: Components): void {
const interpreterQuickPick: IInterpreterQuickPick =
ext.legacyIOC.serviceContainer.get<IInterpreterQuickPick>(IInterpreterQuickPick);
const interpreterPathService: IInterpreterPathService =
ext.legacyIOC.serviceContainer.get<IInterpreterPathService>(IInterpreterPathService);
const interpreterService: IInterpreterService =
ext.legacyIOC.serviceContainer.get<IInterpreterService>(IInterpreterService);
const interpreterQuickPick: IInterpreterQuickPick = ext.legacyIOC.serviceContainer.get<IInterpreterQuickPick>(
IInterpreterQuickPick,
);
const interpreterPathService: IInterpreterPathService = ext.legacyIOC.serviceContainer.get<IInterpreterPathService>(
IInterpreterPathService,
);
const interpreterService: IInterpreterService = ext.legacyIOC.serviceContainer.get<IInterpreterService>(
IInterpreterService,
);
const pathUtils = ext.legacyIOC.serviceContainer.get<IPathUtils>(IPathUtils);
registerAllCreateEnvironmentFeatures(
ext.disposables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export class InterpreterAutoSelectionService implements IInterpreterAutoSelectio

private readonly autoSelectedInterpreterByWorkspace = new Map<string, PythonEnvironment | undefined>();

private globallyPreferredInterpreter: IPersistentState<PythonEnvironment | undefined> =
this.stateFactory.createGlobalPersistentState<PythonEnvironment | undefined>(
preferredGlobalInterpreter,
undefined,
);
private globallyPreferredInterpreter: IPersistentState<
PythonEnvironment | undefined
> = this.stateFactory.createGlobalPersistentState<PythonEnvironment | undefined>(
preferredGlobalInterpreter,
undefined,
);

constructor(
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export abstract class BaseInterpreterSelectorCommand implements IExtensionSingle

public abstract activate(): Promise<void>;

protected async getConfigTargets(options?: { resetTarget?: boolean }): Promise<
protected async getConfigTargets(options?: {
resetTarget?: boolean;
}): Promise<
| {
folderUri: Resource;
configTarget: ConfigurationTarget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
const pythonPathValue = this.interpreterPathService.inspect(this.workspaceFolder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
const pythonPathValue = this.interpreterPathService.inspect(this.workspace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>(IPythonExecutionFactory);
const pythonExecutionFactory = this.serviceContainer.tryGet<IPythonExecutionFactory>(
IPythonExecutionFactory,
);
const pythonExecutionService = pythonExecutionFactory
? await pythonExecutionFactory.create({ resource })
: undefined;
Expand Down
4 changes: 2 additions & 2 deletions extensions/positron-python/src/client/logging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function tracing<T>(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<void>)
((result as unknown) as Promise<void>)
.then((data) => {
log({ elapsed: timer.elapsedTime, returnValue: data });
return data;
Expand Down Expand Up @@ -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);
}
}

Expand Down
Loading

0 comments on commit 360d03b

Please sign in to comment.