Skip to content

Commit d9c00fb

Browse files
Kartik Rajkarthiknadig
authored andcommitted
Only call component adapter behind the discovery experiment (#15459)
1 parent 9f7789a commit d9c00fb

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

src/client/pythonEnvironments/discovery/locators/index.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
CURRENT_PATH_SERVICE,
1717
GetInterpreterLocatorOptions,
1818
GLOBAL_VIRTUAL_ENV_SERVICE,
19-
IComponentAdapter,
2019
IInterpreterLocatorHelper,
2120
IInterpreterLocatorService,
2221
KNOWN_PATH_SERVICE,
@@ -182,12 +181,6 @@ export class WorkspaceLocators extends LazyResourceBasedLocator {
182181
}
183182
}
184183

185-
// The parts of IComponentAdapter used here.
186-
interface IComponent {
187-
hasInterpreters: Promise<boolean | undefined>;
188-
getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[] | undefined>;
189-
}
190-
191184
/**
192185
* Facilitates locating Python interpreters.
193186
*/
@@ -207,10 +200,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
207200
Promise<PythonEnvironment[]>
208201
>();
209202

210-
constructor(
211-
@inject(IServiceContainer) private serviceContainer: IServiceContainer,
212-
@inject(IComponentAdapter) private readonly pyenvs: IComponent,
213-
) {
203+
constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) {
214204
this._hasInterpreters = createDeferred<boolean>();
215205
serviceContainer.get<Disposable[]>(IDisposableRegistry).push(this);
216206
this.platform = serviceContainer.get<IPlatformService>(IPlatformService);
@@ -231,12 +221,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
231221
}
232222

233223
public get hasInterpreters(): Promise<boolean> {
234-
return this.pyenvs.hasInterpreters.then((res) => {
235-
if (res !== undefined) {
236-
return res;
237-
}
238-
return this._hasInterpreters.completed ? this._hasInterpreters.promise : Promise.resolve(false);
239-
});
224+
return this._hasInterpreters.completed ? this._hasInterpreters.promise : Promise.resolve(false);
240225
}
241226

242227
/**
@@ -256,10 +241,6 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
256241
*/
257242
@traceDecorators.verbose('Get Interpreters')
258243
public async getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[]> {
259-
const envs = await this.pyenvs.getInterpreters(resource, options);
260-
if (envs !== undefined) {
261-
return envs;
262-
}
263244
const locators = this.getLocators(options);
264245
const promises = locators.map(async (provider) => provider.getInterpreters(resource));
265246
locators.forEach((locator) => {

src/test/pythonEnvironments/discovery/locators/index.unit.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
CONDA_ENV_SERVICE,
1919
CURRENT_PATH_SERVICE,
2020
GLOBAL_VIRTUAL_ENV_SERVICE,
21-
IComponentAdapter,
2221
IInterpreterLocatorHelper,
2322
IInterpreterLocatorService,
2423
KNOWN_PATH_SERVICE,
@@ -785,21 +784,18 @@ suite('Interpreters - Locators Index', () => {
785784
let serviceContainer: TypeMoq.IMock<IServiceContainer>;
786785
let platformSvc: TypeMoq.IMock<IPlatformService>;
787786
let helper: TypeMoq.IMock<IInterpreterLocatorHelper>;
788-
let pyenvs: TypeMoq.IMock<IComponentAdapter>;
789787
let locator: IInterpreterLocatorService;
790788
setup(() => {
791789
serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>();
792790
platformSvc = TypeMoq.Mock.ofType<IPlatformService>();
793791
helper = TypeMoq.Mock.ofType<IInterpreterLocatorHelper>();
794-
pyenvs = TypeMoq.Mock.ofType<IComponentAdapter>();
795792
serviceContainer.setup((c) => c.get(TypeMoq.It.isValue(IDisposableRegistry))).returns(() => []);
796793
serviceContainer.setup((c) => c.get(TypeMoq.It.isValue(IPlatformService))).returns(() => platformSvc.object);
797-
serviceContainer.setup((c) => c.get(TypeMoq.It.isValue(IComponentAdapter))).returns(() => pyenvs.object);
798794
serviceContainer
799795
.setup((c) => c.get(TypeMoq.It.isValue(IInterpreterLocatorHelper)))
800796
.returns(() => helper.object);
801797

802-
locator = new PythonInterpreterLocatorService(serviceContainer.object, pyenvs.object);
798+
locator = new PythonInterpreterLocatorService(serviceContainer.object);
803799
});
804800
[undefined, Uri.file('Something')].forEach((resource) => {
805801
getNamesAndValues<OSType>(OSType).forEach((osType) => {

0 commit comments

Comments
 (0)