From 1c6fe4d9e59213dbd3328099852c273442aa4a46 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 19 Feb 2021 11:32:23 -0800 Subject: [PATCH] Only call component adapter behind the discovery experiment --- .../discovery/locators/index.ts | 23 ++----------------- .../discovery/locators/index.unit.test.ts | 6 +---- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/client/pythonEnvironments/discovery/locators/index.ts b/src/client/pythonEnvironments/discovery/locators/index.ts index 8a56ba2731f9..07c2b5a8fb66 100644 --- a/src/client/pythonEnvironments/discovery/locators/index.ts +++ b/src/client/pythonEnvironments/discovery/locators/index.ts @@ -16,7 +16,6 @@ import { CURRENT_PATH_SERVICE, GetInterpreterLocatorOptions, GLOBAL_VIRTUAL_ENV_SERVICE, - IComponentAdapter, IInterpreterLocatorHelper, IInterpreterLocatorService, KNOWN_PATH_SERVICE, @@ -182,12 +181,6 @@ export class WorkspaceLocators extends LazyResourceBasedLocator { } } -// The parts of IComponentAdapter used here. -interface IComponent { - hasInterpreters: Promise; - getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise; -} - /** * Facilitates locating Python interpreters. */ @@ -207,10 +200,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi Promise >(); - constructor( - @inject(IServiceContainer) private serviceContainer: IServiceContainer, - @inject(IComponentAdapter) private readonly pyenvs: IComponent, - ) { + constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) { this._hasInterpreters = createDeferred(); serviceContainer.get(IDisposableRegistry).push(this); this.platform = serviceContainer.get(IPlatformService); @@ -231,12 +221,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi } public get hasInterpreters(): Promise { - return this.pyenvs.hasInterpreters.then((res) => { - if (res !== undefined) { - return res; - } - return this._hasInterpreters.completed ? this._hasInterpreters.promise : Promise.resolve(false); - }); + return this._hasInterpreters.completed ? this._hasInterpreters.promise : Promise.resolve(false); } /** @@ -256,10 +241,6 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi */ @traceDecorators.verbose('Get Interpreters') public async getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise { - const envs = await this.pyenvs.getInterpreters(resource, options); - if (envs !== undefined) { - return envs; - } const locators = this.getLocators(options); const promises = locators.map(async (provider) => provider.getInterpreters(resource)); locators.forEach((locator) => { diff --git a/src/test/pythonEnvironments/discovery/locators/index.unit.test.ts b/src/test/pythonEnvironments/discovery/locators/index.unit.test.ts index 3b49f1cfeee6..34843c5d60c1 100644 --- a/src/test/pythonEnvironments/discovery/locators/index.unit.test.ts +++ b/src/test/pythonEnvironments/discovery/locators/index.unit.test.ts @@ -18,7 +18,6 @@ import { CONDA_ENV_SERVICE, CURRENT_PATH_SERVICE, GLOBAL_VIRTUAL_ENV_SERVICE, - IComponentAdapter, IInterpreterLocatorHelper, IInterpreterLocatorService, KNOWN_PATH_SERVICE, @@ -785,21 +784,18 @@ suite('Interpreters - Locators Index', () => { let serviceContainer: TypeMoq.IMock; let platformSvc: TypeMoq.IMock; let helper: TypeMoq.IMock; - let pyenvs: TypeMoq.IMock; let locator: IInterpreterLocatorService; setup(() => { serviceContainer = TypeMoq.Mock.ofType(); platformSvc = TypeMoq.Mock.ofType(); helper = TypeMoq.Mock.ofType(); - pyenvs = TypeMoq.Mock.ofType(); serviceContainer.setup((c) => c.get(TypeMoq.It.isValue(IDisposableRegistry))).returns(() => []); serviceContainer.setup((c) => c.get(TypeMoq.It.isValue(IPlatformService))).returns(() => platformSvc.object); - serviceContainer.setup((c) => c.get(TypeMoq.It.isValue(IComponentAdapter))).returns(() => pyenvs.object); serviceContainer .setup((c) => c.get(TypeMoq.It.isValue(IInterpreterLocatorHelper))) .returns(() => helper.object); - locator = new PythonInterpreterLocatorService(serviceContainer.object, pyenvs.object); + locator = new PythonInterpreterLocatorService(serviceContainer.object); }); [undefined, Uri.file('Something')].forEach((resource) => { getNamesAndValues(OSType).forEach((osType) => {