Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions src/client/pythonEnvironments/discovery/locators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
CURRENT_PATH_SERVICE,
GetInterpreterLocatorOptions,
GLOBAL_VIRTUAL_ENV_SERVICE,
IComponentAdapter,
IInterpreterLocatorHelper,
IInterpreterLocatorService,
KNOWN_PATH_SERVICE,
Expand Down Expand Up @@ -182,12 +181,6 @@ export class WorkspaceLocators extends LazyResourceBasedLocator {
}
}

// The parts of IComponentAdapter used here.
interface IComponent {
hasInterpreters: Promise<boolean | undefined>;
getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[] | undefined>;
}

/**
* Facilitates locating Python interpreters.
*/
Expand All @@ -207,10 +200,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
Promise<PythonEnvironment[]>
>();

constructor(
@inject(IServiceContainer) private serviceContainer: IServiceContainer,
@inject(IComponentAdapter) private readonly pyenvs: IComponent,
) {
constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) {
this._hasInterpreters = createDeferred<boolean>();
serviceContainer.get<Disposable[]>(IDisposableRegistry).push(this);
this.platform = serviceContainer.get<IPlatformService>(IPlatformService);
Expand All @@ -231,12 +221,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
}

public get hasInterpreters(): Promise<boolean> {
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);
}

/**
Expand All @@ -256,10 +241,6 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
*/
@traceDecorators.verbose('Get Interpreters')
public async getInterpreters(resource?: Uri, options?: GetInterpreterLocatorOptions): Promise<PythonEnvironment[]> {
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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
CONDA_ENV_SERVICE,
CURRENT_PATH_SERVICE,
GLOBAL_VIRTUAL_ENV_SERVICE,
IComponentAdapter,
IInterpreterLocatorHelper,
IInterpreterLocatorService,
KNOWN_PATH_SERVICE,
Expand Down Expand Up @@ -785,21 +784,18 @@ suite('Interpreters - Locators Index', () => {
let serviceContainer: TypeMoq.IMock<IServiceContainer>;
let platformSvc: TypeMoq.IMock<IPlatformService>;
let helper: TypeMoq.IMock<IInterpreterLocatorHelper>;
let pyenvs: TypeMoq.IMock<IComponentAdapter>;
let locator: IInterpreterLocatorService;
setup(() => {
serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>();
platformSvc = TypeMoq.Mock.ofType<IPlatformService>();
helper = TypeMoq.Mock.ofType<IInterpreterLocatorHelper>();
pyenvs = TypeMoq.Mock.ofType<IComponentAdapter>();
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>(OSType).forEach((osType) => {
Expand Down