-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Jedi with Jedi LSP #17273
Replace Jedi with Jedi LSP #17273
Conversation
this.languageServerIsDefault = true; | ||
} else if (userLS === 'JediLSP') { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@@ -293,8 +293,12 @@ export class PythonSettings implements IPythonSettings { | |||
userLS === 'Default' || | |||
!Object.values(LanguageServerType).includes(userLS as LanguageServerType) | |||
) { | |||
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.Jedi; | |||
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.None; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 🤷
There was a problem hiding this comment.
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 😂
There was a problem hiding this comment.
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)
@@ -348,4 +345,23 @@ export class LanguageServerExtensionActivationService | |||
const values = await Promise.all([...this.cache.values()]); | |||
values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop())); | |||
} | |||
|
|||
private updateLanguageServerSetting(resource: Resource): void { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
vscode-python/src/client/application/diagnostics/checks/invalidLaunchJsonDebugger.ts
Line 136 in 48d66bd
await this.fixLaunchJson(diagnostic.code); |
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!
@@ -348,4 +345,23 @@ export class LanguageServerExtensionActivationService | |||
const values = await Promise.all([...this.cache.values()]); | |||
values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop())); | |||
} | |||
|
|||
private updateLanguageServerSetting(resource: Resource): void { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this 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?
.github/workflows/pr-check.yml
Outdated
@@ -100,6 +100,10 @@ jobs: | |||
# 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 thebuild-vsix
action which already installs JediLSP requirementsnightly-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) { |
There was a problem hiding this comment.
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 😂
@@ -348,4 +345,23 @@ export class LanguageServerExtensionActivationService | |||
const values = await Promise.all([...this.cache.values()]); | |||
values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop())); | |||
} | |||
|
|||
private updateLanguageServerSetting(resource: Resource): void { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
Yep, there will be 2 follow-up PRs:
|
For #11995
What this PR does:
python.languageServer
, it's all Jedi nowDefault
language server value -> fallback to PylanceJedi
as a language server -> turn the language server offAbout 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.