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. Equip the basedpyright fork for extra diagnostics, baselines and semantic highlighting; those extras are not part of Microsoft Pyright.
- Pyrefly — the artificer.
A growing toolbelt: configurable regex and
mock.patchchecks, framework knowledge, and experimental tensor/DataFrame analysis. Some tools need explicit settings; experimental APIs can change. - ty — the scout. Built for quick incremental feedback, explanatory diagnostics and precise type narrowing. In this adapter, hover favors the type alone and completion resolution is unavailable.
- Zuban — the diplomat. Bridges Mypy workflows and editor inference for untyped code. Compatibility modes are its specialty; value-constrained generic bodies and unused ignores remain checking blind spots.
These are personalities, not speed rankings. The linked field notes separate upstream features from what this library actually tests.
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.
What works here
Diagnostics, hover, completion, signature help and rename pass across all four backends. Semantic tokens work with basedpyright, Pyrefly, ty and Zuban; Microsoft Pyright does not provide them. Completion resolution enriches results with Pyright/basedpyright and Zuban; Pyrefly echoes the item, while ty rejects it.
Verified 2026-09-11: Pyright 1.1.414, basedpyright 1.40.1, Pyrefly 1.3.0, ty 0.0.80, Zuban 0.9.3.
Feature evidence & maintenance runbook · Semantic tokens · Low-level API & lifecycle · Maintenance results
Development
uv sync --all-extras --locked
npm install -g basedpyright
uv run pytest
uvx pyright --pythonpath .venv/bin/python
uvx ruff check .
make generate-latest-types
The runbook covers testing Microsoft Pyright separately, regenerating schemas and updating the browser playground.
Metadata
Release files for lsp-types 0.24.0
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.0.tar.gz | 92.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lsp_types-0.24.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 192.8 kB
Release files / lsp_types-0.24.0.tar.gz
| Download URL | lsp_types-0.24.0.tar.gz |
|---|---|
| Size | 92.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68e7766920d3fed646f2bcddce65e9ec75c5c07e009e7bc8f8eb3936088926cd
|
|
BLAKE2b-256 checksum How to use checksums |
a3172fd177ccc1e5d79b6e2f755e23c9af007ab52900b0fad1111de9fe0bfc72
|
| 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.0-py3-none-any.whl
| Download URL | lsp_types-0.24.0-py3-none-any.whl |
|---|---|
| Size | 100.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82e2a652ee1301285ab838d3b576098d11ea05190951c79d0d192de451ebcfb8
|
|
BLAKE2b-256 checksum How to use checksums |
14281b0267b52090d337bda13153792041c52dba5193922c694025b94e0b6871
|
| 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