Skip to content

Commit

Permalink
Start out with the adapter disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Sep 15, 2020
1 parent 47f9e82 commit 4ce9313
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export interface IVirtualEnvironmentsSearchPathProvider {
export const IComponentAdapter = Symbol('IComponentAdapter');
export interface IComponentAdapter {
// IInterpreterLocatorService
hasInterpreters: Promise<boolean>;
getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[]>;
hasInterpreters: Promise<boolean> | undefined;
getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[] | undefined>;
// IInterpreterService
getInterpreterDetails(pythonPath: string, _resource?: Uri): Promise<undefined | PythonEnvironment>;
// IInterpreterHelper
Expand Down
32 changes: 29 additions & 3 deletions src/client/pythonEnvironments/legacyIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,17 @@ function convertEnvInfo(info: PythonEnvInfo): PythonEnvironment {
class ComponentAdapter implements IComponentAdapter {
constructor(
// The adapter only wraps one thing: the component API.
private readonly api: PythonEnvironments
private readonly api: PythonEnvironments,
// For now we effecitvely disable the component.
private readonly enabled = false
) {}

// IInterpreterHelper

public async getInterpreterInformation(pythonPath: string): Promise<undefined | Partial<PythonEnvironment>> {
if (!this.enabled) {
return undefined;
}
const env = await this.api.resolveEnv(pythonPath);
if (env === undefined) {
return undefined;
Expand All @@ -130,6 +135,9 @@ class ComponentAdapter implements IComponentAdapter {
}

public async isMacDefaultPythonPath(pythonPath: string): Promise<boolean | undefined> {
if (!this.enabled) {
return undefined;
}
const env = await this.api.resolveEnv(pythonPath);
if (env === undefined) {
return undefined;
Expand All @@ -139,7 +147,10 @@ class ComponentAdapter implements IComponentAdapter {

// IInterpreterService

public get hasInterpreters(): Promise<boolean> {
public get hasInterpreters(): Promise<boolean> | undefined {
if (!this.enabled) {
return undefined;
}
const iterator = this.api.iterEnvs();
return iterator.next().then((res) => {
return !res.done;
Expand All @@ -149,6 +160,9 @@ class ComponentAdapter implements IComponentAdapter {
//public async getInterpreters(_resource?: vscode.Uri, _options?: GetInterpreterOptions): Promise<PythonEnvironment[]>;

public async getInterpreterDetails(pythonPath: string, _resource?: vscode.Uri): Promise<undefined | PythonEnvironment> {
if (!this.enabled) {
return undefined;
}
const env = await this.api.resolveEnv(pythonPath);
if (env === undefined) {
return undefined;
Expand All @@ -159,6 +173,9 @@ class ComponentAdapter implements IComponentAdapter {
// ICondaService

public async isCondaEnvironment(interpreterPath: string): Promise<boolean | undefined> {
if (!this.enabled) {
return undefined;
}
const env = await this.api.resolveEnv(interpreterPath);
if (env === undefined) {
return undefined;
Expand All @@ -167,6 +184,9 @@ class ComponentAdapter implements IComponentAdapter {
}

public async getCondaEnvironment(interpreterPath: string): Promise<CondaEnvironmentInfo | undefined> {
if (!this.enabled) {
return undefined;
}
const env = await this.api.resolveEnv(interpreterPath);
if (env === undefined) {
return undefined;
Expand All @@ -184,6 +204,9 @@ class ComponentAdapter implements IComponentAdapter {
// IWindowsStoreInterpreter

public async isWindowsStoreInterpreter(pythonPath: string): Promise<boolean | undefined> {
if (!this.enabled) {
return undefined;
}
const env = await this.api.resolveEnv(pythonPath);
if (env === undefined) {
return undefined;
Expand All @@ -196,7 +219,10 @@ class ComponentAdapter implements IComponentAdapter {
public async getInterpreters(
resource?: vscode.Uri,
_options?: GetInterpreterLocatorOptions
): Promise<PythonEnvironment[]> {
): Promise<PythonEnvironment[] | undefined> {
if (!this.enabled) {
return undefined;
}
// We ignore the options:
//{
// ignoreCache?: boolean
Expand Down

0 comments on commit 4ce9313

Please sign in to comment.