Skip to content

Commit

Permalink
Hide envs before looking for recommendations (#16206)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Nov 7, 2024
1 parent 07e9477 commit 32f3d0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class LocalPythonKernelSelector extends DisposableBase {
if (!this.pythonApi || token.isCancellationRequested) {
return;
}
this.pythonEnvPicker.recommended = findPreferredPythonEnvironment(this.notebook, this.pythonApi);
this.pythonEnvPicker.recommended = findPreferredPythonEnvironment(this.notebook, this.pythonApi, filter);
};
const setupApi = (api?: PythonExtension) => {
if (!api) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ import { isParentPath } from '../../platform/common/platform/fileUtils';
import { EnvironmentType } from '../../platform/pythonEnvironments/info';
import { getEnvironmentType } from '../../platform/interpreter/helpers';
import { Environment, PythonExtension } from '@vscode/python-extension';
import type { PythonEnvironmentFilter } from '../../platform/interpreter/filter/filterService';

export function findPreferredPythonEnvironment(
notebook: NotebookDocument,
pythonApi: PythonExtension
pythonApi: PythonExtension,
filter: PythonEnvironmentFilter
): Environment | undefined {
// 1. Check if we have a .conda or .venv virtual env in the local workspace folder.
const localEnv = findPythonEnvironmentClosestToNotebook(notebook, pythonApi.environments.known);
const localEnv = findPythonEnvironmentClosestToNotebook(
notebook,
pythonApi.environments.known.filter((e) => !filter.isPythonEnvironmentExcluded(e))
);
if (localEnv) {
return localEnv;
}
Expand Down

0 comments on commit 32f3d0b

Please sign in to comment.