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

Add mypy plugin configuration in lsp-pyls #1317

Closed
wants to merge 1 commit into from

Conversation

itome
Copy link
Contributor

@itome itome commented Jan 14, 2020

@yyoncho
Copy link
Member

yyoncho commented Jan 14, 2020

Looks good to me!

@mpanarin willing to take a look?

@mpanarin
Copy link
Collaborator

I don't think this is a good idea.

This is a 3rd party plug-in which is obviously not guaranteed to be installed with pyls (although a lot of pyls users probably do use it)

  1. This defaults are not very good as making it enabled by default implies that it is installed, which can lead to errors in pyls when it is not.
  2. pyls is in progress of implementing its own mypy support (although slow) (Add mypy support using daemon palantir/python-language-server#392) so author efforts should probably be directed there.
  3. When the plugin is installed with pyls it is enabled by default, as well as live_mode - no reason to set it from IDE.

But this rises a different question. @yyoncho is there a way to add parameters to ls dynamically?
As in this case, imagine there would be a reason to enable/disable a feature in the pyls plugin. Maybe some kind of functionality to add parameters like this through dir-locals would be worth it?

@yyoncho
Copy link
Member

yyoncho commented Jan 14, 2020

@yyoncho is there a way to add parameters to ls dynamically?

Can you elaborate?

Maybe some kind of functionality to add parameters like this through dir-locals would be worth it?

You could have dir local with lsp-client-settings. The properties that a server needs are determined by the first token of the path (so-called section).

@itome
Copy link
Contributor Author

itome commented Jan 14, 2020

Take the situation into consideration, I change my mind and think this change confuse users. I'll close this PR if the discussion is finished.

@yyoncho
Copy link
Member

yyoncho commented Jan 14, 2020

When the plugin is installed with pyls it is enabled by default, as well as live_mode - no reason to set it from IDE.

Just want to mention that if the plugin is present these properties could be useful to disable it per project. In general it is up to you(the pyls users) to decide what make sense.

@mpanarin
Copy link
Collaborator

mpanarin commented Jan 14, 2020

Just want to mention that if the plugin is present these properties could be useful to disable it per project. In general it is up to you(the pyls users) to decide what make sense.

You have to install pyls with all of its plugins in each environment anyway, so I don't think it is really usefull here.

You could have dir local with lsp-client-settings. The properties that a server needs are determined by the first token of the path (so-called section).

That is a good idea, thanks!
Although, it can be a bit confusing as it requires adding values to the list in dir-locals instead of settings some variable. Isn't it unsafe?
Maybe it is better to a variable like lsp-ls-additional-params which are passed to language server additionaly to everything else?
This way in dir-locals we would simply set a var and that's it

@yyoncho
Copy link
Member

yyoncho commented Jan 14, 2020

Although, it can be a bit confusing as it requires adding values to the list in dir-locals instead of settings some variable. Isn't it unsafe?

You could set variables as well. The list is useful if you want to alter the set of variables to using dir locals.

@mpanarin
Copy link
Collaborator

You could set variables as well. The list is useful if you want to alter the set of variables to using dir locals.

I understand that. I mean that list manipulations are unsafe in dir-locals, while setting vars is not. And it is a bit more strightforward.

@yyoncho
Copy link
Member

yyoncho commented Jan 28, 2020

@mpanarin can you merge/reject this PR as the owner of lsp-pyls.el?

@mpanarin mpanarin closed this Jan 28, 2020
@yyoncho
Copy link
Member

yyoncho commented Jan 28, 2020

@mpanarin thank you.

@ztlevi
Copy link

ztlevi commented Feb 26, 2020

By seting lsp-clients-settings, I found pyls-mypy enabled is working but live_mode is not working. A better workaround is create a .mypy.ini config file in HOME or mypy.ini in your repo.

@Hi-Angel
Copy link
Contributor

Hi-Angel commented Nov 17, 2020

To have a bit of documentation here: after having pyls-mypy installed, you need to change parameters that are decribed in pyls-mypy README. For lsp-mode you can do this like:

(lsp-register-custom-settings '(("pyls.plugins.pyls_mypy.enabled" t t)
                                ("pyls.plugins.pyls_mypy.live_mode" nil t)
                                ("pylsp.plugins.pylsp_mypy.enabled" t t)
                                ("pylsp.plugins.pylsp_mypy.live_mode" nil t)))

…and if your python directory is not in the project root (for example, if it's located at tests/), don't forget to add the sub-directory as a subroot with (lsp-workspace-folders-add). Otherwise mypy may not be finding modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants