Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Sep 28, 2020
1 parent eb746f9 commit 20c46da
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/client/pythonEnvironments/base/info/pythonVersion.ts
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { EMPTY_VERSION, parseBasicVersionInfo } from '../../../../client/common/utils/version';
import { EMPTY_VERSION, parseBasicVersionInfo } from '../../../common/utils/version';

import { PythonReleaseLevel, PythonVersion } from '.';

Expand Down
42 changes: 25 additions & 17 deletions src/client/pythonEnvironments/base/locatorUtils.ts
Expand Up @@ -30,28 +30,36 @@ export function getQueryFilter(query: PythonLocatorQuery): (env: PythonEnvInfo)
}));
}
}
return (env) => {
if (kinds !== undefined) {
if (!kinds.includes(env.kind)) {
return false;
}
function checkKind(env: PythonEnvInfo): boolean {
if (kinds === undefined) {
return true;
}
return kinds.includes(env.kind);
}
function checkSearchLocation(env: PythonEnvInfo): boolean {
if (env.searchLocation === undefined) {
if (!includeGlobal) {
return false;
}
} else if (locationFilters === undefined) {
// It is not a "rooted" env.
return includeGlobal;
}

// It is a "rooted" env.
if (locationFilters === undefined) {
if (query.searchLocations === null) {
// The caller explicitly refused rooted envs.
return false;
}
if (query.searchLocations && query.searchLocations.length > 0) {
// Only envs without searchLocation set were requested?
return false;
}
} else {
if (!locationFilters.some((filter) => filter(env.searchLocation!))) {
return false;
}
// `query.searchLocations` only had `null` in it.
return !query.searchLocations || query.searchLocations.length === 0;
}
// Check against the requested roots.
return locationFilters.some((filter) => filter(env.searchLocation!));
}
return (env) => {
if (!checkKind(env)) {
return false;
}
if (!checkSearchLocation(env)) {
return false;
}
return true;
};
Expand Down

0 comments on commit 20c46da

Please sign in to comment.