Skip to content

Commit fe1fdcc

Browse files
Start out with the adapter disabled.
1 parent a816665 commit fe1fdcc

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/client/interpreter/contracts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export interface IVirtualEnvironmentsSearchPathProvider {
3434
export const IComponentAdapter = Symbol('IComponentAdapter');
3535
export interface IComponentAdapter {
3636
// IInterpreterLocatorService
37-
hasInterpreters: Promise<boolean>;
38-
getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[]>;
37+
hasInterpreters: Promise<boolean> | undefined;
38+
getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[] | undefined>;
3939
// IInterpreterService
4040
getInterpreterDetails(pythonPath: string, _resource?: Uri): Promise<undefined | PythonEnvironment>;
4141
// IInterpreterHelper

src/client/pythonEnvironments/legacyIOC.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,17 @@ function convertEnvInfo(info: PythonEnvInfo): PythonEnvironment {
116116
class ComponentAdapter implements IComponentAdapter {
117117
constructor(
118118
// The adapter only wraps one thing: the component API.
119-
private readonly api: PythonEnvironments
119+
private readonly api: PythonEnvironments,
120+
// For now we effecitvely disable the component.
121+
private readonly enabled = false
120122
) {}
121123

122124
// IInterpreterHelper
123125

124126
public async getInterpreterInformation(pythonPath: string): Promise<undefined | Partial<PythonEnvironment>> {
127+
if (!this.enabled) {
128+
return undefined;
129+
}
125130
const env = await this.api.resolveEnv(pythonPath);
126131
if (env === undefined) {
127132
return undefined;
@@ -130,6 +135,9 @@ class ComponentAdapter implements IComponentAdapter {
130135
}
131136

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

140148
// IInterpreterService
141149

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

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

161175
public async isCondaEnvironment(interpreterPath: string): Promise<boolean | undefined> {
176+
if (!this.enabled) {
177+
return undefined;
178+
}
162179
const env = await this.api.resolveEnv(interpreterPath);
163180
if (env === undefined) {
164181
return undefined;
@@ -167,6 +184,9 @@ class ComponentAdapter implements IComponentAdapter {
167184
}
168185

169186
public async getCondaEnvironment(interpreterPath: string): Promise<CondaEnvironmentInfo | undefined> {
187+
if (!this.enabled) {
188+
return undefined;
189+
}
170190
const env = await this.api.resolveEnv(interpreterPath);
171191
if (env === undefined) {
172192
return undefined;
@@ -184,6 +204,9 @@ class ComponentAdapter implements IComponentAdapter {
184204
// IWindowsStoreInterpreter
185205

186206
public async isWindowsStoreInterpreter(pythonPath: string): Promise<boolean | undefined> {
207+
if (!this.enabled) {
208+
return undefined;
209+
}
187210
const env = await this.api.resolveEnv(pythonPath);
188211
if (env === undefined) {
189212
return undefined;
@@ -196,7 +219,10 @@ class ComponentAdapter implements IComponentAdapter {
196219
public async getInterpreters(
197220
resource?: vscode.Uri,
198221
_options?: GetInterpreterLocatorOptions
199-
): Promise<PythonEnvironment[]> {
222+
): Promise<PythonEnvironment[] | undefined> {
223+
if (!this.enabled) {
224+
return undefined;
225+
}
200226
// We ignore the options:
201227
//{
202228
// ignoreCache?: boolean

0 commit comments

Comments
 (0)