Closed yaegassy closed 2 years ago
For now revert to stable version.I will investigate asap.I have a likely cause in mind. (We had a change to better support venvs, this might have broken something.) Will probably take two to three evenings to fix. If I cannot reproduce I'll contact you again, otherwise assume that I'm working on it.
I am not able to reproduce this with my editor of choice (spyder with python 3.9.9 though as my OS has not yet updated) and don't really know how to work with vim.
Can you tell me if "mypy check.py" works after activating the venv? Also "which mypy" would be interesting.
What OS are you on?
The steps to reproduce you posted above are not entirely accurate, are you sure this is what you did?
Also, if you could point me at an easy way to configure vim to use pylsp output, I will test that as well.
I use a Vim plugin called "coc.nvim". I developed a plugin called coc-pylsp for coc.nvim by myself and use coc-pylsp.
This problem of the whole pylsp diagnostics crashing occurs when mypy
is not installed in the project.
The point of this problem is that "pylsp + pylsp-mypy" is installed outside of the project's venv.
It is very good that mypy is detected in the project (including venv), but if the detection fails, it might be better to catch the exception and skip it without error, or fall back to mypy installed with pylsp-mypy
Created a PR. https://github.com/Richardk2n/pylsp-mypy/pull/28
Ok, I am very sorry, I had misunderstood, which venv is active, because I have little experience using venvs.
If I understood you right, pylsp-mypy gets executed with a python executable that does not belong to the currently active venv? (Is this considered save given, that things could break, if this python code relies on the variables being set correctly or subprocesses being executed in the same environment?)
So from what I gather, as it currently stands using a project venv to allow mypy to follow imports correctly only works if mypy is installed in said venv and uses the mypy installed in the venv. If mypy is not installed in the project venv but it is active while pylsp-mypy gets called with another executable, the plugin will (understandably) crash.
The best fix would be to fall back to the api call that existed before.
And I should probably recommend to the pylsp devs, that one plugin crashing should not crash the others.
If I understood you right, pylsp-mypy gets executed with a python executable that does not belong to the currently active venv?
@Richardk2n Yes, you are correct in that understanding.
Prepare a venv environment dedicated to pylsp, and use the pylsp installed there for all projects in common.
Since we are not installing in a global python environment, the mypy command that pylsp-mypy depends on does not exist on our PATH.
Some projects (different venvs for pylsp) may not use mypy. In that case, the mypy command does not exist, and you are getting a crash situation.
Probably "issue 26" is the same problem, since it is a pipx installation. https://github.com/Richardk2n/pylsp-mypy/issues/26
The best fix would be to fall back to the api call that existed before.
You can of course use whatever adjustment method you think is best for you. My PR is closed. 🙇
Can you test if it is fixed in the newest release? It is likely fixed.
I have confirmed that the problem has been adjusted. This issue is closed.
Description
I am getting an error in
v0.5.4
of "pylsp-mypy". Due to this error, it seems that no diagnostic messages are sent for pylsp as a whole.This does not seem to be a problem with
v0.5.2
.Repro
Create a venv dedicated to pylsp and install pylsp-mypy in it.
pip list:
Open the python file in an appropriate directory. I use vim.
Error
The pylsp log shows that pylsp-mypy is causing the error. This error causes pylsp itself to not return any diagnostics messages such as flake8 to the LSP client.
It looks like it's trying to detect mypy, but it can't and is giving an error.
Misc
As a side note, if you install pylsp or pylsp-mypy in the venv of the project you are trying to edit, and then run that pylsp, you will not have the problem.
I'm sure there are a lot of people who have installed pylsp outside of the project folder, and in that case, I'm sure they are experiencing the same problem.