Skip to content
Open
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
14 changes: 12 additions & 2 deletions extension/pyenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class PythonEnvironmentManager extends DisposableContext {
private envChangeEmitter: vscode.EventEmitter<void>;
private displayedSDKError: boolean = false;
private lastLoadedEnv: string | undefined = undefined;
private activeSDK: SDK | undefined = undefined;

constructor(logger: Logger, reporter: TelemetryReporter) {
super();
Expand Down Expand Up @@ -178,8 +179,8 @@ export class PythonEnvironmentManager extends DisposableContext {
}
}

/// Load the active SDK from the currently active Python environment, or undefined if one is not present.
public async getActiveSDK(): Promise<SDK | undefined> {
/// Finds the active SDK from the currently active Python environment, or undefined if one is not present.
public async findActiveSDK(): Promise<SDK | undefined> {
assert(this.api !== undefined);
// Prioritize retrieving a monorepo SDK over querying the environment.
const monorepoSDK = await this.tryGetMonorepoSDK();
Expand Down Expand Up @@ -227,6 +228,15 @@ export class PythonEnvironmentManager extends DisposableContext {
}
}

/// Load the active SDK from the currently active Python environment, or undefined if one is not present.
public async getActiveSDK(): Promise<SDK | undefined> {
if (this.activeSDK) {
return this.activeSDK;
}
this.activeSDK = await this.findActiveSDK();
return this.activeSDK;
}

private async displaySDKError(message: string) {
if (this.displayedSDKError) {
return;
Expand Down
Loading