tomv564 / pyls-mypy

Mypy plugin for the Python Language Server
MIT License
110 stars 62 forks source link

Update plugin to use python-lsp-server instead of python-language-server #51

Open andfoy opened 3 years ago

andfoy commented 3 years ago

Hi,

Given that Palantir removed all the community maintenance for both python-language-server (pyls) and python-jsonrpc-server (pyls_jsonrpc), we decided to create a separate organization that now maintains a community-based fork for the aforementioned packages, which can be found at: https://github.com/python-lsp/python-lsp-server and https://github.com/python-lsp/python-lsp-jsonrpc.

Our recommendation is to migrate this plugin to be compatible with the community server instead of the Palantir one. In order to do so, here is a migration guide that should help:

  1. The plugin should replace python-language-server by python-lsp-server on its requirements.
  2. The pyls namespace is now pylsp, which means that all pyls imports should be replaced by pylsp.
  3. The pyls_* hookspecs are now pylsp_* hookspecs.
  4. The plugin can preserve the pyls_ prefix on its namespace in order to prevent further administration and release issues that may arise from renaming it.

Feel free to ask any question about the migration process or about the new community organization for the server.

haplo commented 3 years ago

@tomv564 I created a PR to fix this, if you could review, merge and release a python-lsp-server-compatible version of pyls-mypy that would be much appreciated.

haplo commented 3 years ago

@andfoy There is a maintained fork at https://github.com/Richardk2n/mypy-ls.

@Richardk2n Would you accept #52 to make the project work against https://github.com/python-lsp/python-lsp-server? I can open the PR against your repository.

haplo commented 3 years ago

@andfoy I have reviewed mypy-ls and it looks like a minimalistic fork to improve plugin configuration support, but it hasn't had activity since October. It also has issues disabled, which is a red flag for me.

I think best course of action would be to create another fork at python-lsp/pylsp-mypy and release as a new pylsp-mypy package to PyPI. python-lsp-server can then point to this new repository and package as the maintained version of the plugin. If you add me as a maintainer I can handle the necessary changes.

asford commented 3 years ago

@haplo I'm happy to contribute to that fork.

I would recommend starting from the https://github.com/Richardk2n/mypy-ls fork, as the configuration support is dramatically improved and bring the plugin inline with command-line mypy invocations. My personal fork provides support for dmypy as well as mypy as well as some misc bugfixes for non-live-mode checking. If you'd like to @ me in an issue to provide dmypy support in the fork I can open a PR there.

andfoy commented 3 years ago

If you are willing to maintain the new fork, then I'll move it to the organization later today

haplo commented 3 years ago

@haplo I'm happy to contribute to that fork.

I would recommend starting from the https://github.com/Richardk2n/mypy-ls fork, as the configuration support is dramatically improved and bring the plugin inline with command-line mypy invocations. My personal fork provides support for dmypy as well as mypy as well as some misc bugfixes for non-live-mode checking. If you'd like to @ me in an issue to provide dmypy support in the fork I can open a PR there.

All that sounds good to me, I will bring @Richardk2n improvements for plugin configurability, and will be happy to see your improvements too. Let's get the fork released with python-lsp-server compatibility and then we will keep improving it. Hopefully the community will stop getting fragmented and everybody can contribute to a single upstream project.

BTW I just switched to non-live-mode myself and it's working much better, so I'm looking forward to your bugfixes in that regard. :)

If you are willing to maintain the new fork, then I'll move it to the organization later today

You can sign me up for it, I'm an active user of mypy and the LSP plugin.

Richardk2n commented 3 years ago

@haplo I enabled issues. I did not intend for them to be disabled. I'll happily include any suggestions and would love to see this plugin getting some attention.

haplo commented 3 years ago

@haplo I enabled issues. I did not intend for them to be disabled. I'll happily include any suggestions and would love to see this plugin getting some attention.

Great to hear from you @Richardk2n.

I have no interest in creating yet another fork of the plugin if you are available as a maintainer. If you could merge https://github.com/Richardk2n/mypy-ls/pull/2 and release a new python-lsp-server-compatible version we can ask @andfoy to point to your fork as the recommended mypy plugin.

Please be aware that @andfoy mentioned that python-lsp-server might integrate a mypy plugin in the future, but until then we need to maintain the third-party plugin.

GaetanLepage commented 3 years ago

What is the current state of the mypy integration to python-lsp-server ? Is the plan still to create a fork within the python-lsp organization ?

Richardk2n commented 3 years ago

What is the current state of the mypy integration to python-lsp-server ? Is the plan still to create a fork within the python-lsp organization ?

Currently my fork mypy-ls is working with python-lsp-server (as far as i know). And given, that I keep maintaining it there is no plan to fork it on the organization until they decide to integrate mypy support directly into python-lsp-server (as far as i know).

GaetanLepage commented 3 years ago

Great ! I just installed it thanks to pip install mypy-ls. How is it configurable though ? When I was using palantir's python-language-server, I was configuring the mypy plugin in this way: https://github.com/tomv564/pyls-mypy#configuration.

Now that I am using python-lsp-server, am I still able to configure it through the language server config ? As editor, I am using neovim.

Richardk2n commented 3 years ago

It should be configurable as before. However as I never really figured out where the config should be placed (I would be grateful If you could tell me, where and how python-language-server expects its configs) there is a possibility, that I might ignore those passed to the language server. You can try. If it doesn't work place a file with your config formatted as in here in your working directory or a parent of said directory.

I would be grateful for feedback about what works, and how people are using the plugin, as my testing does not cover all use cases.

GaetanLepage commented 3 years ago

Hello ! Sorry for having waited before answering. Actually, this fork of the mypy plugin works fine for me with the following configuration section in the language client:

pylsp_mypy = {
    enabled = true,
    live_mode = false
},
haplo commented 3 years ago

Actually, this fork of the mypy plugin works fine for me with the following configuration section in the language client:

Does it work when you uninstall python-language-server and install only python-lsp-server? I would be surprised because the imports in the plugin code are different, I would expect either errors or the plugin not being registered at all.

GaetanLepage commented 3 years ago

It seems that I only have python-lsp-server available right now.

[I] ➜ pip show python-language-server
WARNING: Package(s) not found: python-language-server

~ 
[I] ➜ pip show python-lsp-server     
Name: python-lsp-server
Version: 1.1.0.dev0
Summary: Python Language Server for the Language Server Protocol
Home-page: https://github.com/python-lsp/python-lsp-server
Author: Python Language Server Contributors
Author-email: None
License: UNKNOWN
Location: /home/gaetan/.local/lib/python3.9/site-packages
Requires: jedi, python-lsp-jsonrpc, pluggy, ujson, setuptools
Required-by: mypy-ls

And it works. However, I don't know teh exact way both mypy-ls and python-lsp-server interact.

haplo commented 3 years ago

@GaetanLepage OK, that is expected, mypy-ls (now renamed to pylsp-mypy) works with python-lsp-server. pyls-mypy on the other hand works with python-language-server, which as the original message in this issue points out, is not maintained anymore. I thought your original comment regarded pyls-mypy, hence my confusion.

GaetanLepage commented 3 years ago

Thank you for this useful clarification !