Skip to content

Commit 5847336

Browse files
lint
1 parent dbcddad commit 5847336

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

src/client/pythonEnvironments/base/info/pythonVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { EMPTY_VERSION, parseBasicVersionInfo } from '../../../../client/common/utils/version';
4+
import { EMPTY_VERSION, parseBasicVersionInfo } from '../../../common/utils/version';
55

66
import { PythonReleaseLevel, PythonVersion } from '.';
77

src/client/pythonEnvironments/base/locatorUtils.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,36 @@ export function getQueryFilter(query: PythonLocatorQuery): (env: PythonEnvInfo)
3030
}));
3131
}
3232
}
33-
return (env) => {
34-
if (kinds !== undefined) {
35-
if (!kinds.includes(env.kind)) {
36-
return false;
37-
}
33+
function checkKind(env: PythonEnvInfo): boolean {
34+
if (kinds === undefined) {
35+
return true;
3836
}
37+
return kinds.includes(env.kind);
38+
}
39+
function checkSearchLocation(env: PythonEnvInfo): boolean {
3940
if (env.searchLocation === undefined) {
40-
if (!includeGlobal) {
41-
return false;
42-
}
43-
} else if (locationFilters === undefined) {
41+
// It is not a "rooted" env.
42+
return includeGlobal;
43+
}
44+
45+
// It is a "rooted" env.
46+
if (locationFilters === undefined) {
4447
if (query.searchLocations === null) {
48+
// The caller explicitly refused rooted envs.
4549
return false;
4650
}
47-
if (query.searchLocations && query.searchLocations.length > 0) {
48-
// Only envs without searchLocation set were requested?
49-
return false;
50-
}
51-
} else {
52-
if (!locationFilters.some((filter) => filter(env.searchLocation!))) {
53-
return false;
54-
}
51+
// `query.searchLocations` only had `null` in it.
52+
return !query.searchLocations || query.searchLocations.length === 0;
53+
}
54+
// Check against the requested roots.
55+
return locationFilters.some((filter) => filter(env.searchLocation!));
56+
}
57+
return (env) => {
58+
if (!checkKind(env)) {
59+
return false;
60+
}
61+
if (!checkSearchLocation(env)) {
62+
return false;
5563
}
5664
return true;
5765
};

0 commit comments

Comments
 (0)