Skip to content

Do not resolve inside iterEnvs in low-level locators#16642

Merged
karrtikr merged 28 commits into
microsoft:mainfrom
karrtikr:pluckresolver
Jul 15, 2021
Merged

Do not resolve inside iterEnvs in low-level locators#16642
karrtikr merged 28 commits into
microsoft:mainfrom
karrtikr:pluckresolver

Conversation

@karrtikr
Copy link
Copy Markdown

@karrtikr karrtikr commented Jul 9, 2021

Closes https://github.com/microsoft/vscode-python-internalbacklog/issues/310

Just focus on the lines added and it won't seem much 😉 All changes are very similar.

This changes the low-level locators to return BasicEnvInfo instead of PythonEnvInfo, which just contains two fields: kind and executablePath.

Key changes:

  • Change ILocator interface to support return generic types, so low-level locators return BasicEnvInfo, meanwhile the API, resolver etc. can still return PythonEnvInfo.
  • This rippled through code and had to change certain base classes to adopt the new return type as well.
  • Plucked resolving from path locator to created resolver to resolve globally installed environments.
  • The rest is deleted code.

@karrtikr karrtikr added the no-changelog No news entry required label Jul 9, 2021
Kartik Raj added 2 commits July 14, 2021 17:47
@karrtikr karrtikr marked this pull request as ready for review July 15, 2021 01:01
@karrtikr karrtikr requested a review from kimadeline July 15, 2021 01:08
Comment on lines +118 to +120
function resolveEnvCollision(oldEnv: BasicEnvInfo, newEnv: BasicEnvInfo): BasicEnvInfo {
const [env] = sortEnvInfoByPriority(oldEnv, newEnv);
return env;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see this function is only used in one place, can we replace its call with sortEnvInfoByPriority directly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually have a follow up PR where we do more stuff inside resolveEnvCollision.

function resolveEnvCollision(oldEnv: BasicEnvInfo, newEnv: BasicEnvInfo): BasicEnvInfo {
    const [env] = sortEnvInfoByPriority(oldEnv, newEnv);
    const merged = cloneDeep(env);
    merged.source = uniq((oldEnv.source ?? []).concat(newEnv.source ?? []));
    return merged;
}

So I'll keep it as is for this PR.

@karrtikr karrtikr merged commit 919ea9e into microsoft:main Jul 15, 2021
@karrtikr karrtikr deleted the pluckresolver branch July 15, 2021 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants