Skip to content

Replace Jedi with Jedi LSP#17273

Merged
kimadeline merged 32 commits intomicrosoft:mainfrom
kimadeline:11995-use-jedi-lsp-
Sep 13, 2021
Merged

Replace Jedi with Jedi LSP#17273
kimadeline merged 32 commits intomicrosoft:mainfrom
kimadeline:11995-use-jedi-lsp-

Conversation

@kimadeline
Copy link
Copy Markdown

@kimadeline kimadeline commented Sep 3, 2021

For #11995

What this PR does:

  • remove the JediLSP experiment
  • remove the JediLSP option under python.languageServer, it's all Jedi now
  • the Jedi option in the settings now refers to what used to be JediLSP
  • deleted Jedi tests that are failing now that old Jedi is out of commission
  • if on Python 2.7 and using the Default language server value -> fallback to Pylance
  • if on Python 2.7 and explicitly using Jedi as a language server -> turn the language server off

About the last 2 bullet points, I will add a notification that says "IntelliSense with Jedi for Python 2.7 is no longer supported. Learn more." in a separate PR.

@kimadeline kimadeline added the skip package*.json package.json and package-lock.json don't both need updating label Sep 3, 2021
@kimadeline kimadeline self-assigned this Sep 3, 2021
Comment thread src/client/activation/common/defaultlanguageServer.ts
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.Jedi;
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.None;
this.languageServerIsDefault = true;
} else if (userLS === 'JediLSP') {
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.

@jakebailey did you mean this settings parser?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, exactly; this is the "untrusted" part where we validate the user's settings before actually casting them to the enum.

!Object.values(LanguageServerType).includes(userLS as LanguageServerType)
) {
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.Jedi;
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.None;
Copy link
Copy Markdown
Member

@jakebailey jakebailey Sep 7, 2021

Choose a reason for hiding this comment

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

Trying to remember, but I believe that there was some test that relied on this staying Jedi, some weird case where there can't be a default LS present yet (since the default LS thing is possibly undefined). Maybe after removing old Jedi, this turns out fine.

// If the interpreter is Python 2 and the LS setting is explicitly set to Jedi, turn it off.
// If set to Default, use Pylance.
if (interpreter && (interpreter.version?.major ?? 0) < 3) {
if (serverType === LanguageServerType.Jedi) {
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.

If I have the inner condition the other way around (if default -> node, else if jedi -> none) then the 2.7 debugger tests break 🤷

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reverting the condition can change the language server as the default LS can be Jedi as well, although not sure how intellisense affects debugger 😂

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.

Reverting the condition can change the language server as the default LS can be Jedi as well

True!

although not sure how intellisense affects debugger 😂

The debugger tests spawn a VS Code instance, it's something about the extension activating and not finding Pylance (not sure why it causes an activation failure instead of displaying the "Pylance is not installed, do you want to install it" message though)

values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop()));
}

private updateLanguageServerSetting(resource: Resource): void {
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.

Do you think there's a better spot where this could be done? It feels weird updating the settings.json file here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do similar this in testing too. But we have the code in a separate file. (See updateTestSettings.ts). I don't think we have a convention for this, and it seems ok to do it here.

Ideally we would have a settings manager and we would register this as a change provider with that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I assume this is just for settings migration. We do have a diagnostics convention for stuff like this, ideally updateTestSettings.ts should be a diagnostic too. See

lsNotSupportedDiagnosticService.handle(diagnostic).ignoreErrors();

for example.

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 assume this is just for settings migration.

Yes, it replaces the JediLSP value of the python.languageServer setting with Jedi.

Looking at the LSNotSupportedDiagnosticService class it seems to only display an information message, and doesn't migrate settings?

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'm going to display the "Python 2.7 isn't supported" notification as a diagnostic, so I'm going to move the settings migration there in that PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looking at the LSNotSupportedDiagnosticService class it seems to only display an information message, and doesn't migrate settings?

Yes, the point I was making was it could be used for migration.

is probably a better example where we migrate.

I'm going to display the "Python 2.7 isn't supported" notification as a diagnostic, so I'm going to move the settings migration there in that PR.

Great!

@kimadeline kimadeline marked this pull request as ready for review September 9, 2021 22:22
values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop()));
}

private updateLanguageServerSetting(resource: Resource): void {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do similar this in testing too. But we have the code in a separate file. (See updateTestSettings.ts). I don't think we have a convention for this, and it seems ok to do it here.

Ideally we would have a settings manager and we would register this as a change provider with that.

return;
}

this.configurationService.updateSetting('languageServer', LanguageServerType.Jedi, resource, configTarget);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it a good idea to change this? It's no longer a valid enum value but is still accepted by the settings parser.

People may have checked in these settings, so I'd be wary of forcibly changing them to something else at startup, but maybe it won't be too many people.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could leave it to show squiggles for a few releases and later remove it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Removing it from package.json will effectively do this, so that's okay.

I don't have a strong preference; I know that Pylance has migration code for old MPLS settings, so I guess we're already accepting setting migrations. Have the same thing here already (though in that other test settings migrator thingy).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We do migrations like this all the time for launch.json, or other settings like python.unitTest to python.testing, so I don't think this should be a problem.

Copy link
Copy Markdown

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

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

Mostly LGTM. Do you plan to remove completion.py and other Jedi related code later?

Comment thread .github/workflows/pr-check.yml Outdated
# We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase.
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy

- name: Install JediLSP requirements
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is pr-check.yml the only place where we need to do this?

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.

There are 2 other actions that require Jedi LSP bits:

  • build.yml, which relies on the build-vsix action which already installs JediLSP requirements
  • nightly-coverage.yml, I'll add it there as well 👍

// If the interpreter is Python 2 and the LS setting is explicitly set to Jedi, turn it off.
// If set to Default, use Pylance.
if (interpreter && (interpreter.version?.major ?? 0) < 3) {
if (serverType === LanguageServerType.Jedi) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reverting the condition can change the language server as the default LS can be Jedi as well, although not sure how intellisense affects debugger 😂

values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop()));
}

private updateLanguageServerSetting(resource: Resource): void {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I assume this is just for settings migration. We do have a diagnostics convention for stuff like this, ideally updateTestSettings.ts should be a diagnostic too. See

lsNotSupportedDiagnosticService.handle(diagnostic).ignoreErrors();

for example.

return;
}

this.configurationService.updateSetting('languageServer', LanguageServerType.Jedi, resource, configTarget);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We do migrations like this all the time for launch.json, or other settings like python.unitTest to python.testing, so I don't think this should be a problem.

@kimadeline
Copy link
Copy Markdown
Author

@karrtikr

Do you plan to remove completion.py and other Jedi related code later?

Yep, there will be 2 follow-up PRs:

  • one to add the notification about 2.7 support
  • one to remove all the old Jedi code

@kimadeline kimadeline merged commit 862a88d into microsoft:main Sep 13, 2021
@kimadeline kimadeline deleted the 11995-use-jedi-lsp- branch September 13, 2021 23:56
@kimadeline kimadeline added this to the September 2021 milestone Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip package*.json package.json and package-lock.json don't both need updating

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants