Skip to content

Is Pyright a Python language server? #309

Closed

Description

@huppyflup

Pyright is in the list of language servers but the repo says that it's a: "Static Type Checker for Python" (https://github.com/microsoft/pyright).
With its command-line tool it doesn't seem to behave like an lsp.

Activity

  1. keegancsmith commented on May 31, 2023

    @keegancsmith
    Collaborator

    I am not sure. I think its best to follow up with the pyright community. They mention the LSP but maybe our links our now outdated? https://github.com/microsoft/pyright#community

  2. huppyflup commented on Jun 2, 2023

    @huppyflup
    Author

    The community section from your link says “language service functionality is associated with Pylance”, but it is mentioned as lsp in the docs in
    https://microsoft.github.io/pyright/#/installation?id=language-server and
    https://microsoft.github.io/pyright/#/features?id=language-server-support.
    I don’t know if one of these is a better link because the docs seems to lack how it’s used as an lsp. The only thing I found is microsoft/pyright#3515

    (Interestingly the microsoft list of language servers lists neither pylance nor pyright https://microsoft.github.io/language-server-protocol/implementors/servers/)

  3. andrewcrook commented on Jul 26, 2023

    @andrewcrook

    @huppyflup

    (Interestingly the microsoft list of language servers lists neither pylance

    pylance is a LSP that now only works with VSCode and Visual Studio I am not sure there is any point listing it really because its not open to LSP clients in general. Microsoft now refers to it as "fully integrate support”.

    I am not sure but I think pyright needs a wrapper to turn it into a LSP. Pyright is actually used as a part of pylance so that’s probably why, because they want you to use their products.

  4. huppyflup commented on Aug 30, 2023

    @huppyflup
    Author

    If it needs a wrapper should then the wrapper be listed instead?

  5. andrewcrook commented on Aug 30, 2023

    @andrewcrook

    If it needs a wrapper should then the wrapper be listed instead?

    Do you know of a pyright LSP wrapper?
    I don’t.

    I’ve seen wrappers as in plugins using it as a command line tool for editors like a linter or static analyser are often wrapped. But I haven't seen one which makes it an actual LSP server. It might be used as a part of a third party LSP with other tools, again if you can find and it if it exists.

    There is a plugin on neovim which fakes it as a LSP called null_ls but it’s not an actual fully compatible LSP, only runs on neovim and the author recently announced that he’s archiving the project. Again, you either need to find one or write one.

    I know pyright is used in Microsofts pylance but as I said this LSP isn't open to any other LSP clients apart from Microsofts own which defeats the whole idea of LSPs tbh and I think its a bit off on Microsofts behalf.

    also there are other Python LSPs

  6. Pegasust commented on Oct 4, 2023

    @Pegasust

    pyright provides pyright the CLI to type-check and report, you could theoretically write extend it as a static type checker by using pyright --json. Another big player for static typing that is officially embraced by Python core is mypy, which is used by python-lsp-server as a type-checking backend.

    pyright does ship with the lsp: pyright-langserver, where common invocation for an LSP client is pyright-langserver --stdio, see Neovim's lspconfig

    So yes, pyright is a Python LSP that supports static type checking based on couple of PEP in pure TypeScript (so it theoretically does not require the Python interpreter, as long as you have the bundled executable) and resort to typestubs for external library type information before optionally using Python interpreter and toolings to resolve and deduce transitive type context onto our project/package

  7. huppyflup commented on Oct 10, 2023

    @huppyflup
    Author

    I can agree, that with pyright-langserver it's a language server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions