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 support for pyright #2472

Closed
alok opened this issue May 2, 2019 · 8 comments
Closed

Add support for pyright #2472

alok opened this issue May 2, 2019 · 8 comments
Labels
new tool Support for new linters, fixers, etc.

Comments

@alok
Copy link

alok commented May 2, 2019

Name: foobar
URL: https://foo.bar.com

https://github.com/Microsoft/pyright Like mypy.

@w0rp w0rp added the new tool Support for new linters, fixers, etc. label May 2, 2019
@w0rp
Copy link
Member

w0rp commented May 2, 2019

microsoft/pyright#99 I left a comment here asking how a command line utility for starting the language server for other editors like Vim can be built. I think it's worth building that, instead of running it from scratch from the command line.

@lkgarrison
Copy link

I'd love to see this. I've tried mypy, pytype, and pyre, and I have to say, pyright has blown me away so far. It's type checker is much better and seems to catch many more edge cases that other checkers simply miss.

I'd be happy to help add support for pyright in Ale. However, I'm uncertain how to go about doing that.

It sounds like we need two things:

  1. An ALE linter plugin for pyright. My best guess is this would look similar to the pyre linter?
  2. To be able to run pyright as a Language Server.

While I'm fuzzy on the details of how LSP-compatible fixers are configured, I'm more uncertain about how to go about #2. From microsoft/pyright#99, it sounds as though pyright itself can't currently be used to run the Language Server in a stand-alone way. But I'm unclear why not. Is it too tightly coupled with VSCode? Or would it need an additional CLI command to start up the language server that they don't want to add? I was surprised to see them pushing for a separate project that would expose the language server for other IDEs. It seems a bit silly and against the spirit of LSP to develop a tool like that that is only compatible with VSCode?

Any advice on how best to proceed would be great!

@w0rp
Copy link
Member

w0rp commented Sep 22, 2019

I think someone needs to write a pyright CLI tool in JavaScript/TypeScript. At the moment clients can only connect to pyright if they are written in JavaScript/TypeScript and import the JavaScript/TypeScript code.

@fannheyward
Copy link
Contributor

@alok @lkgarrison you can use pyright in vim/neovim with coc-pyright+coc.nvim, and they all works well with ALE. https://github.com/fannheyward/coc-pyright

@LanderMoerkerke
Copy link

To elaborate on this further, I see that there is a node cli app available: https://github.com/microsoft/pyright/#command-line

So it is possible possible to use it without importing it trough JS/TS code.

@dsifford
Copy link
Contributor

It's now possible to add this to ALE as of microsoft/pyright#810

If someone doesn't jump on this and open a PR before me, I might be able to get to it in the next week or two (time allowing).

@w0rp
Copy link
Member

w0rp commented Aug 6, 2020

I'll probably try to add support for this myself.

Some rambling on what I want to do with it... I was thinking of using pyls with the mypy plugin, because I use Django at work, but then there's no VSCode marketplace extension for pyls, which my colleagues use a lot. pyright doesn't support a mypy plugin for working out the actual types of Django models, but I figure I can just write a makemigrations hook that automatically writes .pyi files to get around that.

@w0rp w0rp closed this as completed in 19229e8 Aug 7, 2020
@w0rp
Copy link
Member

w0rp commented Aug 7, 2020

I've added pyright as a supported tool now, and it is enabled by default. I was able to set up the configuration so the virtualenv path and executable are automatically set by default, and can be overridden. See :help ale-python-pyright for the options and installation instructions for pyright itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new tool Support for new linters, fixers, etc.
Projects
None yet
Development

No branches or pull requests

6 participants