Replace Jedi with Jedi LSP#17273
Conversation
| this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.Jedi; | ||
| this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.None; | ||
| this.languageServerIsDefault = true; | ||
| } else if (userLS === 'JediLSP') { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
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.
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.
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 { |
There was a problem hiding this comment.
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.
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.
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
for example.
There was a problem hiding this comment.
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.
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.
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.
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!
| values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop())); | ||
| } | ||
|
|
||
| private updateLanguageServerSetting(resource: Resource): void { |
There was a problem hiding this comment.
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.
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.
We could leave it to show squiggles for a few releases and later remove it?
There was a problem hiding this comment.
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.
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.
karrtikr
left a comment
There was a problem hiding this comment.
Mostly LGTM. Do you plan to remove completion.py and other Jedi related code later?
| # 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.
Is pr-check.yml the only place where we need to do this?
There was a problem hiding this comment.
There are 2 other actions that require Jedi LSP bits:
build.yml, which relies on thebuild-vsixaction 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.
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 { |
There was a problem hiding this comment.
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
for example.
| return; | ||
| } | ||
|
|
||
| this.configurationService.updateSetting('languageServer', LanguageServerType.Jedi, resource, configTarget); |
There was a problem hiding this comment.
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 nowDefaultlanguage server value -> fallback to PylanceJedias 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.