question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pyright-langserver

See original GitHub issue

Description

I’m trying to configure pyright as a Python language server, but haven’t had much success.

Reproduce

So far I have managed to get the jupyterlab-lsp installed (after struggling with some Internal Server 500 errors):

% jupyter labextension list             
JupyterLab v3.0.7
Other labextensions (built into JupyterLab)
   app dir: /home/jdsmith/.local/share/jupyter/lab
        @krassowski/completion-theme v2.0.0 enabled OK
        @krassowski/jupyterlab-lsp v3.4.1 enabled OK

Uninstalled core extensions:
    @krassowski/jupyterlab-lsp

But I don’t get any additional completion/underlining/etc. features.

Expected behavior

I hoped to see underlines and signatures/etc. provided by pyright.

Context

  • Language Server: pyright-langserver
  • Language Server version: 1.1.113
  • Language Server installed with: npm
  • Language Server Spec

I have also added the following file as pyright.json to /etc/jupyter/jupyter_notebook_config.d

{
  "pyright-langserver": {            # the name of the implementation
      "version": 1,                      # the version of the spec schema
      "argv": ["pyright-langserver", "--stdio"],  # a list of command line arguments
      "languages": ["python"]            # a list of languages it supports
  }
}

I’m not certain if this is the right location to implement a new server spec. In fact I found the docs lacking there: lots of descriptions of what might go in such a spec file to configure a new LSP server, but no mention I could find of where to put it!

Before I dump a bunch of files on you, I want to see how I might learn whether juptyerlab_lsp is in fact running, and if it has found (and rejected?) the langserver spec. I looked for [lsp] output in a --debug run of jupyter lab, but did not see any mentions.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
yuntancommented, Apr 26, 2021

I found that setting python.analysis.useLibraryCodeForTypes to true works for popups.

default useLibraryCodeForTypes: true
Screenshot 2021-04-26 21 02 55 Screenshot 2021-04-26 21 08 48

Open “Advanced Settings Editor” > “Language Server” and edit “User Preferences”.

{
    "language_servers": {
        "pyright": {
            "serverSettings": {
                "python.analysis.useLibraryCodeForTypes": true
            }
        }
    }
}

Then restart Jupyter.

Note Starting with numpy 1.20 type stubs are included in numpy. Pyright uses type stubs for completion and popups. useLibraryCodeForTypes: true is effective for packages without type stubs (like pandas).

0reactions
krassowskicommented, May 23, 2021

Closing as pyright auto-detection was added in #587 and will be available in the next version 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

microsoft/pyright: Static type checker for Python - GitHub
Pyright is a fast type checker meant for large Python source bases. It can run in a “watch” mode and performs fast incremental...
Read more >
Lsp pyright - LSP Mode - LSP support for Emacs
For more information about the LSP server, check pyright-langserver. Installation#. For more instructions on how to install manually, check here. Debugger: Yes#.
Read more >
pyright · PyPI
Pyright for Python is a Python command-line wrapper over pyright, a static type checker for Python. Installation. Use the package manager pip to...
Read more >
Pyright language server not working? : r/neovim - Reddit
I have the Pyright language server setup in Neovim. ... This is currently not possible, the pyright lang server only starts inside projects...
Read more >
pyright 1.1.285-1 (any) - Arch Linux
Architecture: any. Repository: Community. Description: Type checker for the Python language. Upstream URL: https://github.com/microsoft/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found