Add "Default" LS setting, which picks between Jedi/Pylance - #16139
Add "Default" LS setting, which picks between Jedi/Pylance#16139Jake Bailey (jakebailey) wants to merge 5 commits into
Conversation
| "None" | ||
| ], | ||
| "default": "Jedi", | ||
| "default": "Default", |
There was a problem hiding this comment.
Should I remove this change now?
There was a problem hiding this comment.
Seems fine for now, why do you think this needs to be removed?
There was a problem hiding this comment.
This one can probably stay regardless, but the other code makes Pylance the default (and IDK when we want to actually flip that switch; this PR or another.
| "python.languageServer": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "Default", |
There was a problem hiding this comment.
I think this block could use an enumDescriptions to define the semantics of each of these.
There was a problem hiding this comment.
Here you go: #16141
| private readonly interpreterPathService?: IInterpreterPathService, | ||
| private readonly interpreterSecurityService?: IInterpreterSecurityService, | ||
| private readonly defaultJedi?: IDefaultLanguageServer, | ||
| private readonly defaultLS?: IDefaultLanguageServer, |
There was a problem hiding this comment.
The meaning of IDefaultLanguageServer has changed to return what "Default" will mean; before it also checked the user's settings, which was too much. This file is what actually determines the final result.
| userLS === 'Default' || | ||
| !Object.values(LanguageServerType).includes(userLS as LanguageServerType) | ||
| ) { | ||
| ls = this.defaultLS?.defaultLSType ?? LanguageServerType.Jedi; |
There was a problem hiding this comment.
defaultLS can be undefined, so I had to hardcode some default here, but I'm honestly not sure under which conditions this can be the case.
There was a problem hiding this comment.
Since you removed the condition in setDefaultLanguageServer I don't see why it would ever be undefined either, unless this instance gets added before setDefaultLanguageServer is called?
There was a problem hiding this comment.
I tried making it required, and hit a bunch of places that simply don't have access to the data needed, so IDK what's going on there.
| experimentService: IExperimentService, | ||
| extensions: IExtensions, | ||
| ): Promise<PotentialDefault> { | ||
| if (extensions.getExtension<ILSExtensionApi>(PYLANCE_EXTENSION_ID)) { |
There was a problem hiding this comment.
I would have liked to call activate here and figure out of Pylance is functional or not, but Pylance hard deps on Python, and this means that activate will block forever due to the cycle.
We'll have to rely on later checks to fallback to Jedi.
| "None" | ||
| ], | ||
| "default": "Jedi", | ||
| "default": "Default", |
There was a problem hiding this comment.
Seems fine for now, why do you think this needs to be removed?
|
Added Karthik Nadig (@karthiknadig) because he did the JediLSP work |
…new-default-ls-setting
|
We'll probably want to change vscode-python/src/client/activation/activationService.ts Lines 236 to 241 in fb6b722 Is Python 2 going away anytime soon? :) |
|
Fixed the title; no idea why it did that. |
|
What happened |
|
GH really did not like that. I'll have to rebase and resend. |
| if ( | ||
| !userLS || | ||
| userLS === 'Default' || | ||
| !Object.values(LanguageServerType).includes(userLS as LanguageServerType) |
There was a problem hiding this comment.
Not sure what this condition signifies. Does this mean if user has selected an invalid LS value, we select the default LS in those cases?
There was a problem hiding this comment.
Correct. We can't trust user values from enums, so this checks for invalid ones and then selects the default if they are present. That's sort of the problem with the VS code settings API; it's too easy to make mistakes.
| import { ILSExtensionApi } from '../node/languageServerFolderService'; | ||
| import { LanguageServerType } from '../types'; | ||
|
|
||
| export type PotentialDefault = LanguageServerType.Jedi | LanguageServerType.JediLSP | LanguageServerType.Node; |
There was a problem hiding this comment.
Good catch; this should be with IDefaultLanguageServer.
Adds a new "Default" setting, which implies Pylance when Pylance installed, otherwise uses jedi (plus/minus the LSP experiment).
For https://github.com/microsoft/vscode-python-internalbacklog/issues/176.