LSP Types
Typed Python interfaces for the Language Server Protocol, with async sessions
and process pooling for Python language servers. Built on
Sublime LSP’s generated types.
Python 3.12+; one runtime dependency, tomlkit.
🧙 Meet your party
- 🛡️ Pyright — the sentinel. Broad typing support and configurable execution environments. Choose basedpyright for extra diagnostics, baselines and semantic highlighting.
- 🔧 Pyrefly — the artificer.
Framework-aware analysis with opt-in regex and
mock.patchchecks. - 🏹 ty — the scout. Incremental analysis, explanatory diagnostics and precise type narrowing.
- 🤝 Zuban — the diplomat. Mypy-compatible configuration and editor inference for untyped code.
🚀 Start a session
pip install "lsp-types[pyrefly]" # Or [ty] / [zuban]
import asyncio
from pathlib import Path
from tempfile import TemporaryDirectory
from lsp_types import Session
from lsp_types.pyrefly.backend import PyreflyBackend
async def main():
with TemporaryDirectory() as workspace:
session = await Session.create(
PyreflyBackend(),
base_path=Path(workspace),
initial_code='answer: int = "oops"',
)
try:
print(await session.get_diagnostics())
await session.update_code("answer: int = 42")
print(await session.get_diagnostics()) # []
finally:
await session.shutdown()
asyncio.run(main())
Swap in TyBackend, ZubanBackend, or PyrightBackend. For Pyright, install
Node.js and npm install -g pyright (or basedpyright) separately.
Sessions write backend configuration into base_path; use a dedicated workspace
as above. For types alone, import lsp_types; no server is needed.
✨ Features
All four backends support diagnostics, hover, completion, signature help and rename.
| Feature | Pyright | basedpyright | Pyrefly | ty | Zuban |
|---|---|---|---|---|---|
| Semantic highlighting | ❌ | ✅ | ✅ | ✅ | ✅ |
| Completion documentation via resolve | ✅ | ✅ | ❌ | ❌ | ✅ |
Pyrefly returns completion items unchanged on resolve; ty does not support the request. ty hover returns the type without the symbol name.
📖 API & lifecycle · 🎨 Semantic tokens · 🧭 Backend guide · 🎮 Browser playground
🛠️ Development
uv sync --all-extras --locked
npm install -g basedpyright
uv run pytest tests
uvx pyright --pythonpath .venv/bin/python
uvx ruff check .
make generate-latest-types
Metadata
Release files for lsp-types 0.24.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lsp_types-0.24.1.tar.gz | 87.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lsp_types-0.24.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 182.5 kB
Release files / lsp_types-0.24.1.tar.gz
| Download URL | lsp_types-0.24.1.tar.gz |
|---|---|
| Size | 87.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1daa5a049e5d2a10f1c42587b718d7c579713d0b292721b2a6f78375fdc058e
|
|
BLAKE2b-256 checksum How to use checksums |
30cd0a89f84b444689c45f1e5d32474e2c8b1ee7bbaa350d0e431d1d396ef4be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / lsp_types-0.24.1-py3-none-any.whl
| Download URL | lsp_types-0.24.1-py3-none-any.whl |
|---|---|
| Size | 95.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d4ee5fcae498a15fbacc2f0d86d2290b425d3de2ff7afc63df35789ca0a1556
|
|
BLAKE2b-256 checksum How to use checksums |
e2866319083881b3189f4f115d20452678d63984c16488593e127e2288fde98c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency log