Skip to content

Commit 80f5fb7

Browse files
Mazyodclaude
andcommitted
docs: update CLAUDE.md and README.md to reflect current project state
- Fix test command examples to use actual test file paths - Update dependency claims from "zero-dependency" to "minimal-dependency" - Add requests.py documentation to Core Components - Fix backend integration paths (session.py → backend.py) - Correct schema source references (pyrefly.schema.json → pyrefly-guide.md) - Update testing strategy to document parametrized approach - Add examples/ directory documentation - Fix README example with proper imports and shutdown call - Correct Makefile target reference (generate-schemas → generate-types) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 04431f6 commit 80f5fb7

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

CLAUDE.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Always use `uv` for Python operations:
99
```bash
1010
# Run tests
1111
uv run pytest # All tests
12-
uv run pytest tests/test_pool.py # Generic pool tests
13-
uv run pytest tests/test_pyright/ # Pyright-specific tests
14-
uv run pytest tests/test_pool.py::TestLSPProcessPool::test_name -v # Single pool test
12+
uv run pytest tests/test_pool.py # Pool tests
13+
uv run pytest tests/test_session.py # Session tests
14+
uv run pytest tests/test_pool.py::TestLSPProcessPool::test_name -v # Single test
1515

1616
# Generate latest LSP types (full pipeline)
1717
make generate-latest-types # Downloads schemas + generates all types
@@ -25,7 +25,7 @@ make generate-types # Generate final type definitions
2525

2626
## Architecture Overview
2727

28-
This is a zero-dependency Python library providing typed LSP (Language Server Protocol) interfaces with optional process management.
28+
This is a minimal-dependency Python library providing typed LSP (Language Server Protocol) interfaces with optional process management.
2929

3030
### Core Components
3131

@@ -47,6 +47,12 @@ This is a zero-dependency Python library providing typed LSP (Language Server Pr
4747
- Consolidated implementation with common LSP functionality shared across all backends
4848
- Standard interface for `shutdown()`, `update_code()`, `get_diagnostics()`, etc.
4949

50+
**Request/Notification Functions (`lsp_types/requests.py`)**
51+
- `RequestFunctions`: Typed async methods for all LSP requests (initialize, hover, completion, etc.)
52+
- `NotificationFunctions`: Typed methods for LSP notifications (initialized, didOpen, didChange, etc.)
53+
- Auto-generated from LSP schema to provide full protocol coverage
54+
- Used internally by `LSPProcess.send` and `LSPProcess.notify` interfaces
55+
5056
**Generic Process Pooling (`lsp_types/pool.py`)**
5157
- `LSPProcessPool`: Language-server agnostic process pooling for performance optimization
5258
- `PooledLSPProcess`: Wrapper for `LSPProcess` with recycling state management
@@ -56,15 +62,13 @@ This is a zero-dependency Python library providing typed LSP (Language Server Pr
5662
**Backend Integrations**
5763

5864
**Pyright Integration (`lsp_types/pyright/`)**
59-
- `PyrightBackend`: Backend implementation for Pyright LSP server
65+
- `backend.py`: `PyrightBackend` implementation for Pyright LSP server
6066
- `config_schema.py`: Auto-generated Pyright configuration types
61-
- `session.py`: Factory functions and backward-compatible wrappers
6267
- **Key Design**: Uses consolidated `Session` class with `PyrightBackend` for specialization
6368

6469
**Pyrefly Integration (`lsp_types/pyrefly/`)**
65-
- `PyreflyBackend`: Backend implementation for Pyrefly LSP server (Facebook's Rust-based type checker)
70+
- `backend.py`: `PyreflyBackend` implementation for Pyrefly LSP server (Facebook's Rust-based type checker)
6671
- `config_schema.py`: Pyrefly configuration types (TypedDict with known fields)
67-
- `session.py`: Factory functions and backward-compatible wrappers
6872
- **Key Design**: Uses consolidated `Session` class with `PyreflyBackend` for specialization
6973
- **Config Flexibility**: Supports arbitrary configuration fields via TOML serialization (using `tomli-w`)
7074

@@ -73,7 +77,7 @@ This is a zero-dependency Python library providing typed LSP (Language Server Pr
7377
**Schema Sources:**
7478
- `assets/lsprotocol/lsp.schema.json`: Official LSP protocol schema
7579
- `assets/lsps/pyright.schema.json`: Pyright-specific configuration schema
76-
- `assets/lsps/pyrefly.schema.json`: Pyrefly-specific configuration schema
80+
- `assets/lsps/pyrefly-guide.md`: Pyrefly configuration documentation (manually defined types)
7781

7882
**Generation Process:**
7983
1. `download_schemas.py`: Fetches latest schemas from upstream
@@ -82,20 +86,21 @@ This is a zero-dependency Python library providing typed LSP (Language Server Pr
8286

8387
### Testing Strategy
8488

85-
**Process Pool Tests**
86-
- `tests/test_pool.py`: Direct `LSPProcessPool` testing with generic interface
87-
- `tests/test_pyright/test_session_pool.py`: Pool integration testing through Pyright sessions
88-
- `tests/test_pyrefly/test_session_pool.py`: Pool integration testing through Pyrefly sessions
89+
**Tests are parametrized to run against multiple backends (Pyright and Pyrefly).**
90+
91+
**Process Pool Tests (`tests/test_pool.py`)**
92+
- Direct `LSPProcessPool` testing with generic interface
93+
- Parametrized fixtures for testing both Pyright and Pyrefly backends
8994
- Comprehensive pool behavior testing (creation, recycling, limits, cleanup)
9095
- Performance benchmarks comparing pooled vs non-pooled sessions
9196
- Concurrent usage scenarios and idle process management
9297

93-
**Session Tests**
94-
- `tests/test_session.py`: Core consolidated Session class functionality
95-
- `tests/test_pyright/test_pyright_session.py`: Pyright-specific LSP functionality testing
96-
- `tests/test_pyrefly/test_pyrefly_session.py`: Pyrefly-specific LSP functionality testing
98+
**Session Tests (`tests/test_session.py`)**
99+
- Core consolidated Session class functionality
100+
- Parametrized fixtures for testing both Pyright and Pyrefly backends
97101
- Integration testing with actual language servers (diagnostics, hover, completion)
98-
- Backend-specific configuration and behavior validation
102+
- Dynamic environment testing with temporary directories
103+
- Backend-agnostic tests that validate common LSP operations
99104

100105
### Dependencies
101106

@@ -109,6 +114,12 @@ This is a zero-dependency Python library providing typed LSP (Language Server Pr
109114

110115
**Note:** Previously a zero-dependency library. Added `tomli-w` to support arbitrary configuration fields in Pyrefly backend.
111116

117+
### Examples
118+
119+
The `examples/` directory contains demo scripts showing library usage:
120+
- `pyrefly_diagnostics_completion.py`: Demonstrates diagnostics and code completion with Pyrefly
121+
- `pyrefly_circular_imports.py`: Example of detecting circular import issues
122+
112123
### Important Notes
113124

114125
- Always prefix test commands with `uv run`

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ _Publish the excellent work of [Sublime LSP](https://github.com/sublimelsp/lsp-p
1212

1313
__LSP Types__ is a Python package that aims to provide a fully typed interface to Language Server Protocol (LSP) interactions. It can be used to simply utilize the types, or to interact with an LSP server over stdio.
1414

15-
It is a goal to maintain zero-dependency status for as long as possible.
15+
The library has minimal dependencies (`tomli-w` for TOML config serialization).
1616

1717
## Installation
1818

@@ -66,14 +66,17 @@ The following LSPs are available out of the box:
6666
### Pyright Example
6767

6868
```python
69+
from lsp_types import Session
70+
from lsp_types.pyright.backend import PyrightBackend
71+
6972
async def test_pyright_session():
7073
code = """\
7174
def greet(name: str) -> str:
7275
return 123
7376
"""
7477

75-
pyright_session = await Session.create(PyrightBackend(), initial_code=code)
76-
diagnostics = await pyright_session.get_diagnostics()
78+
session = await Session.create(PyrightBackend(), initial_code=code)
79+
diagnostics = await session.get_diagnostics()
7780

7881
assert diagnostics != []
7982

@@ -82,10 +85,11 @@ def greet(name: str) -> str:
8285
return f"Hello, {name}"
8386
"""
8487

85-
assert await pyright_session.update_code(code) == 2
86-
87-
diagnostics = await pyright_session.get_diagnostics()
88+
await session.update_code(code)
89+
diagnostics = await session.get_diagnostics()
8890
assert diagnostics == []
91+
92+
await session.shutdown()
8993
```
9094

9195
## Development
@@ -105,7 +109,7 @@ make download-schemas
105109

106110
Generate the types:
107111
```sh
108-
make generate-schemas
112+
make generate-types
109113
```
110114

111115
Copy the `lsp_types/types.py` file to your project.

0 commit comments

Comments
 (0)