multilspy

raw JSON →
0.0.15 verified Fri May 01 auth: no python

multilspy is a language-agnostic LSP (Language Server Protocol) client library for Python, providing a high-level interface to interact with language servers. Current version is 0.1.0 (pre-release), with a stable v0.0.15. It supports Python, Rust, Java, Go, JavaScript, Ruby, C#, Dart, PHP, and Elixir. Development is active, with regular releases.

pip install multilspy
error ModuleNotFoundError: No module named 'pwd'
cause Windows systems do not have the pwd Unix module. multilspy <0.0.15 imported pwd unconditionally.
fix
pip install multilspy>=0.0.15
error AssertionError: None
cause Assertion failures in `request_references` or `request_document_symbols` without a message, making debugging hard. Seen in versions <0.0.15.
fix
Upgrade to multilspy>=0.0.15 where assertions include descriptive messages.
error TypeError: 'NoneType' object is not callable
cause The `Multilspy` constructor expects a language server identifier (string), but passing None or incorrect type causes this error.
fix
Ensure you pass a valid language server name (e.g., 'pylsp', 'rust-analyzer').
gotcha On Windows, multilspy may fail with 'No module named pwd' if the system does not have the pwd module. This was fixed in v0.0.15, but older versions are affected.
fix Upgrade to multilspy>=0.0.15
deprecated The `request_references` and `request_document_symbols` methods may raise assertion errors without messages in older versions. Debugging is difficult.
fix Use multilspy>=0.0.15 or catch AssertionError explicitly.
breaking In v0.1.0 (pre-release), the API may have changed significantly. The async `LanguageServer` class may replace `Multilspy`. Stick to stable v0.0.15 for now.
fix Pin to multilspy>=0.0.15,<0.1.0 or test thoroughly with v0.1.0.

Basic usage: start a language server, open a file, request completions, then stop.

import os
from multilspy import Multilspy

# Initialize multilspy with a language server (Python in this case)
lsp = Multilspy(os.environ.get('PYTHON_LSP', 'pylsp'))
# Start the language server
lsp.start()
# Open a Python file
with open('example.py', 'w') as f:
    f.write('import os\n\nprint(os.getcwd())')
lsp.open_document('example.py')
# Get completions
completions = lsp.request_completions('example.py', line=1, character=0)
print(completions)
lsp.close_document('example.py')
lsp.stop()