-
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
Make it possible to use the LSP to talk to Jedi #13855
Conversation
python-jsonrpc-server==0.2.0 \ | ||
--hash=sha256:59ce9c9523c14c493a327b3a27ee37464a36dc2b9d8ab485ecbcedd38840380a \ | ||
# via -r requirements.in | ||
click==7.1.2 # via jedi-language-server |
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.
Hashes don't seem to work with git hub dependencies. At least I haven't figured out how to make them work. Still looking into it.
package.json
Outdated
"All" | ||
] | ||
}, | ||
"description": "List of experiment to opt into. If empty, user is assigned the default experiment groups. See https://github.com/microsoft/vscode-python/wiki/Experiments for more details.", | ||
"scope": "machine" | ||
"scope": "resource" |
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.
These need to be per machine, we cannot have user opt into an experiment in one workspace & not the other.
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.
Why not?
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.
This is required to get the tests to pass. Otherwise I have to do something like write the global settings.json or create an environment variable that overrides this in the actual source code.
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 this only a problem in multiple workspaces?
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 the requirement is to get the tests to pass, then you can easily update this package.json during tests (that's what I do in native notebooks), i.e. in tests update the scope.
Else we're changing functionality of the product here, just for tests to pass, & i don' think that's the right thing.
Example:
- User opts into experiment that deprecate pythonPath setting,
- User opens another worksapce, now VS Code will complainin about python path not being setup
I.e. our code needs to be written in such a way that experiments are scoped to a workspace instance & not global. Today we assume that user is in experiment. We don't assume that an instance of vs code is in an experiment
.
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 we want to change this behavior thats fine, i'd leave this for core team to decide.
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.
Okay I put it back. Test startup code writes the package.json now.
package.json
Outdated
"All" | ||
] | ||
}, | ||
"description": "List of experiment to opt out of. If empty, user is assigned the default experiment groups. See https://github.com/microsoft/vscode-python/wiki/Experiments for more details.", | ||
"scope": "machine" | ||
"scope": "resource" |
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.
See previous comment.
Codecov Report
@@ Coverage Diff @@
## main #13855 +/- ##
==========================================
- Coverage 60.03% 59.82% -0.22%
==========================================
Files 685 691 +6
Lines 38086 38337 +251
Branches 5487 5515 +28
==========================================
+ Hits 22866 22934 +68
- Misses 14039 14219 +180
- Partials 1181 1184 +3
Continue to review full report at Codecov.
|
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 think the changes to the scope are leftovers of the tests
const jediServerModulePath = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'runJediLanguageServer.py'); | ||
const interpreter = await this.interpreterService.getActiveInterpreter(resource); | ||
const pythonPath = interpreter ? interpreter.path : 'python'; | ||
const args = [`${jediServerModulePath}`]; |
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.
const args = [`${jediServerModulePath}`]; | |
const args = [jediServerModulePath]; |
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 that was silly. I was original putting quotes around it, but not necessary.
"noFallthroughCasesInSwitch": true | ||
"noFallthroughCasesInSwitch": true, | ||
"resolveJsonModule": true, | ||
"removeComments": true |
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.
Why are we removing the comments?
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.
So I can import json with comments. Didn't think comments were necessary and it makes reading the settings.json super simple.
@@ -99,6 +99,10 @@ export enum SurveyAndInterpreterTipNotification { | |||
surveyExperiment = 'pythonMailingListPromptWording' | |||
} | |||
|
|||
// Experiment to switch Jedi to use an LSP instead of direct providers | |||
export enum JediLSP { | |||
experiment = '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.
Do we need seprate Enums?
I'm not sure why we ended up creating 1 enum for each experiment.
Why not create an enum named Experiments
and we always use that single enum. Then its strongly typed as well, rather than just accepting strings.
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.
FYI - I know this is how the old stuff has been written, just never understand why, its more stuff that needs to be imported & the experiments are not strongly typed (as we just accept strings, & we need to dig around to find the right enum).
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.
Yeah I'm not going to change it now. We can enter an issue if you want to refactor this stuff.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@karthiknadig can you take a look when you get the chance? Thanks |
|
||
# Trick language server into thinking it started from 'jedi-language-server.exe' | ||
sys.argv[0] = "jedi-language-server.exe" | ||
sys.exit(cli()) |
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 should file this as a bug. We should be able to run this python EXTENSION_ROOT/pythonFiles/lib/python
the same way we run debugpy
. We won't need this file.
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 think this is particular to how we're installing it. If you pip install it, it generates an exe in your scripts folder that you would normally use (that exe has this exact code in 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.
This script does not restrict running this only to windows. So argv[0] will be wrong for linux/mac. The problem is in the package itself. You should be able to just run via __main__.py
in that package. This is a fairly small change, and it preservers existing functionality. Secondly, the package itself won;t require installation to run. since we don;t want to install this for each python environment.
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.
Oh there is no __main__.py
in the package. So maybe adding that would fix the 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.
We don't install this for every environment. We run it like we ran jedi. It ships as part of the VSIX.
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.
Yep, it is a simple enough fix. We can take that later. For now lets get this working.
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 know we don;t install for every environment. My point was that the package is designed in a way where it expects that. Hence you had to add this script to run it. But really it should not require installation nor should it require this script. The problem is with the packaging.
For #11995
This is the beginning of the work to switch to the Jedi LSP. It installs a fork of https://github.com/pappasam/jedi-language-server and sets up an experiment to control whether or not to use it.
Still left to do:
The goal here is to submit this and then split up the work of fixing the bugs in our fork and then push the changes the original pappasam main fork.
I forked it here: https://github.com/vscode-python/jedi-language-server