Skip to content
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

JSON config does not recognize Pylance as language server #16

Closed
kovalensue opened this issue Jul 1, 2020 · 23 comments
Closed

JSON config does not recognize Pylance as language server #16

kovalensue opened this issue Jul 1, 2020 · 23 comments
Labels
bug Something isn't working

Comments

@kovalensue
Copy link

Hello,

I've just installed Pylance and started playing with it. In JSON config file I found this:

image

Pylance seems to be working:

image

My python version:
image

I think VSCode config file should recognize Pylance as a new language server.

Regards,
Tom

@gramster
Copy link
Member

gramster commented Jul 1, 2020

Hi Tom

We will likely add it as a valid language server setting option in the Python extension at some point so it doesn't get squiggled. However, as the set of choices in the Python extension must be statically declared, and as pylance is a separate extension and in early release, we felt that that was premature and installing it with a prompt to enable should be enough for now (and you can uninstall/disable the extension to turn it off).

It is probably worth making this clearer in the documentation.

@carlocardella
Copy link
Member

we felt that that was premature and installing it should be enough to enable it for now (and you can uninstall/disable the extension to turn it off).

Sorry, to clarify: should we still add Pylance as language server and ignore the warning? Or are you saying that Pylance becomes the language server just because it is installed and enabled?

@erictraut
Copy link
Contributor

For now, add Pylance as language server and ignore the warning. Otherwise, it won't work.

@Magnus512
Copy link

For now, add Pylance as language server and ignore the warning. Otherwise, it won't work.

HI there I'm nre in this, how can we add pylance as language server ?

@erictraut
Copy link
Contributor

When you install Pylance, it should pop up a dialog asking you if you'd like to make it the default language server for Python. Click "Yes", and it will update your settings accordingly.

If you want to update your settings manually, set "python.languageServer" to "Pylance" as in the image at the top of this thread.

@blakeinate
Copy link

I noticed that while the pop up dialog does correctly update my user's language server settings, no changes are made to the active workspace. Would you consider adding a second prompt for workspace updates as well?

@jakebailey
Copy link
Member

We expect to add Pylance to the declared set of settings to get rid of the squiggle and improve the prompt to better handle workspace settings, yes.

For the initial release, we limited the set of behaviors down to be more managable (as there are quite a number of places to set the setting and orderings to install things).

@judej judej added the bug Something isn't working label Jul 9, 2020
@Magnus512
Copy link

Pylint is still needed after pylance installation ?

@jakebailey
Copy link
Member

They do similar but different things. For live syntax errors and many other messages, pylint wouldn't be required, but there may be warnings/errors that pylint provides you may still use. AFAIK currently pylint won't run if an LS is enabled.

@Magnus512
Copy link

Got it 👍

@ymyke
Copy link

ymyke commented Jul 13, 2020

When I switch python.languageServer to Pylance I get this message "Please reload the window switching between language engines." prompting me to reload the settings window and also any (Python?) window I switch to. I have to ignore the message to keep Pylance enabled. Because if I do the reload, the setting switches back to what it was before (Jedi, in my case).

@Kit139
Copy link

Kit139 commented Jul 27, 2020

pylance安装后仍然需要pylint吗?

No

@jakebailey
Copy link
Member

microsoft/vscode-python#13123 will add Pylance to the Python extension's choice list (as well as handle all of the edge cases that happen due to being able to change the setting whenever). We'll see when we can get it into a release of the extension. After that happens, Pylance will appear in the UI and not be warned in the settings.

@Orionsg
Copy link

Orionsg commented Jul 31, 2020

@jakebailey

I logged an issue pertaining to Microsoft Pythong Language Server and noticed this suggestion in the inital bug reporting instruction text:

"[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]"

This made me install PyLance, since I thought that the issue I reported might have been corrected in the PyLance Language server. However, I then got a message suggesting an automatic change of the default Python language server to PyLance, which I accepted, but then there was the problem of the setting not being accepted as described above. I kept getting the message about the setting not being accepted even though reloading VSCode.

I did read the explanation under #192 . Fine, that the pythong language server PyLance setting will only be accepted in the insiders build and not the stable version. However, in that case I think you should remove the general suggestion to install PyLance when reporting an issue in core Microsoft Python extension -- or just fix it so the setting works in the stable version.

Make a decision!
I find it wrong to broadly suggest a new extension that gives continual warnings, which one then wastes time trying to fix and yet even more, searching Github to find solutions and be helpful in reporting this issue. You guys also waste time having to address the issue again and again.

@jakebailey
Copy link
Member

jakebailey commented Jul 31, 2020

I think you may have misread #192. Pylance works with the stable build of the Python extension. The only difference is that it's not listed in the Python extension's package.json, so isn't in the UI and a warning appears when you open the JSON file (which can be safely ignored). If you set the setting manually and install Pylance (as per the readme), it should work fine. There is a known issue where the prompt may be confused if you set the languageServer setting somewhere other than globally, but should work past that.

Pylance was released as a preview with a limited install path as there are numerous edge cases to consider when two extensions are required. We are opening up more ways to get it, and most of these issues will be solved at the next Python extension release.

If you are saying that you have the setting set globally and don't have it set anywhere else, and you are using an official build of VS Code, and it's still not working, then we would appreciate a new issue with logs and system info to help us debug the problem.

@Orionsg
Copy link

Orionsg commented Jul 31, 2020

I tried again just now:

a) Installed Pylance

b) The message came up immediately: "Would you like to make Pylance your default language server for Python?" I select "yes, and reload". This leads to an eternal loop, i.e. VS Code reloads and the same prompt comes up again, If one ignores the prompt, it dissappears after a while but comes again when VS Code is started the next time.

c) In both User and Workspace settings, one can only select "Microsoft", "Jedi" or "None". As you mention, though, one can set the setting manually in settings.json for the user.

d) The PyLance language server may then work. But I keep getting the message "Would you like to make Pylance your default language server for Python?" when I start VS Code.

The Quick Start section in the PyLance extension page does not metion any of these issues and states that one can update the setting through the prompt:
"3. Select Yes when prompted to make Pylance the default lanuguage server. This will update your preferences, which you can also do manually by adding "pythong.lanugageServer": "Pylance" to your settings.json file using the text editor."

Now, I am not sure if the described behaviour is just for my installation or this is how it works for everyone. But I hope you can understand that I find it confusing when I install this extension, following the instructions under "Quick Start" and then get an eternally looping prompt to change the default language server and reload, if I select Yes.

Here is the system info:
VS Code version: VS Code 1.47.3
Extension version (available under the Extensions sidebar): Python v2020.7.96456
OS and version: Windows 10, x64, 10.0.18363
Python version (& distribution if applicable, e.g. Anaconda): Python 3.8 (Windows store installation)
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A

I am not that experienced with the logs of VS Code, so if you need them perhaps you can instruct me as to which logs are needed and where they are located.

@jakebailey
Copy link
Member

The prompt is appearing because there's somewhere in your config change that is changing languageServer away from Pylance such that it wouldn't load. I would check every place a config could appear (user settings, remote settings, workspace settings, etc) to ensure that it's only in the user settings.

This is the aforementioned known issue with the prompt; we are working on this.

@jakebailey
Copy link
Member

If you open a python file then check the "Python Language Server" output window, does it appear to be running Pylance, or something else?

@Orionsg
Copy link

Orionsg commented Jul 31, 2020

It says: "Starting Microsoft Python language server.".
I have checked the settings.json and it has:
"python.languageServer": "Pylance" (There is an orange underlining, which says "Value not accepted ...", but I guess that is to be expected).

Which other places can the setting be located, which would override the settings.json setting?
And can these be changed manually as well?

@jakebailey
Copy link
Member

In some config file somewhere, you have "python.languageServer": "Microsoft", as the default would be Jedi. Check in files like .vscode/settings.json in your workspace, or in a .code-workspace file. If this is WSL, it may have been set in the remote settings. If you use the command palette, you can search "JSON" and find the user config.

The fix will be for the prompt to set Pylance in the one that it detects as the "active" setting (since it knows where it read the setting from), but for now you'll have to find where it's been set by hand.

@Orionsg
Copy link

Orionsg commented Jul 31, 2020

I found a settings.json in the project folder, which was set to Microsoft Language Server. However, I think that it has lower priority than the user settings.json, so the prompt still comes up.

I am not going to use anymore time on this but will just await the next release, which you say will fix the issue.
I certainly look forward to see Pylance in action.

Jake, thanks for the effort in troubleshooting this and have a nice weekend!

Best regards,
Frank

@jakebailey
Copy link
Member

The workspace/project has higher priority than the user settings (user settings are the lowest, in fact).

@savannahostrowski
Copy link
Contributor

As of today's Python extension release (v2020.8.101144), Pylance has been added as a supported language server value so you should no longer see a warning on that string in your settings.json.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests