New(ish) Python LSP server which works with Emacs: basedpyright
Python. So many lsp-server options. Which one is "the right one"
lsp for python, sure. but which lsp server??
Videos
A new to me LSP server for Python has appeared: basedpyright. This is a fork of the fast pyright langserver which Microsoft develops, with a more OSS philosophy. It has lots of improvements bringing it close to (and in some cases surpassing) the proprietary, MS VSCode-only LSP server pylance which wraps pyright:
Basedpyright is a fork of pyright with various type checking improvements, improved vscode support and pylance features built into the language server.
You can read about all the improvements over pyright. The one most meaningful to me is "docstrings for compiled builtin modules". E.g. docs with eglot go from:
pyright:
class range(
stop: SupportsIndex,
/
)to
basedpyright:
class range(
stop: SupportsIndex,
/
)
range(stop) -> range object
range(start, stop[, step]) -> range object
Return an object that produces a sequence of integers from start (inclusive)
to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.
start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.
These are exactly the valid indices for a list of 4 elements.
When step is given, it specifies the increment (or decrement).
Recent eglot versions already support it: just pip install basedpyright. Works fine with lsp-booster and all the normal settings.
After years of enjoying freedom from writing Python code, I now find myself reluctantly returning to this once familiar territory, and almost instantly got overwhelmed with decision fatigue.
At the moment, I can't figure out which lsp-server to use. There's:
-
pylsp,
-
jedi,
-
palantir-made (deprecated),
-
microsoft made (deprecated),
-
microsoft made pyright,
-
stripped down version of it - pyright-based,
-
rust made ruff,
-
PyDev (does it even work with Emacs?),
-
C#-made, archived and unmaintained python-language-server
It'd be fine if there was just some overlapping functionality, but it seems they all have some features that just don't work. Like for example python-lsp-server can't let you browse workspace symbols. Which for me, honestly, really is a deal breaker. I use consult-lsp-symbols command all the time.
And then after choosing an lsp-server, I have to tune up some checking, linting features, and I'm not sure which one of these are "relevant": black or yapf or ruff, flake8, rope, mypy, pydocstyle, pylint, jedi; OMG, why are there so many linters?
What do you folks use? I thought configuring Emacs for web dev these days was a hassle - I had no idea how messy the Python world has become.
there seem to be many python lsp server implementations. a quick google search didn't yield an obvious winner. is there a list somewhere? a comparison? do python devs have any strong opinions to share about which one to use?