You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add requires_file_on_disk protocol for backend-specific file handling
Add LSPBackend.requires_file_on_disk() protocol method to allow backends
to declare whether they need files written to disk for analysis. This
fixes ty backend which cannot analyze virtual documents without
corresponding files on disk.
Changes:
- Add requires_file_on_disk() to LSPBackend protocol
- Implement in PyrightBackend (False), PyreflyBackend (False), TyBackend (True)
- Session.create() now writes initial code to disk when required
- Session.update_code() keeps disk files in sync
- Update tests to use tmp_path/base_path to avoid stray files in project root
- Remove xfails for ty tests that now pass (diagnostics, completion, rename, recycling)
- Update ty KNOWN_LIMITATIONS.md to document automatic handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: lsp_types/ty/KNOWN_LIMITATIONS.md
+14-17Lines changed: 14 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
This document describes known limitations and behavioral differences when using the ty backend compared to other LSP backends (Pyright, Pyrefly).
4
4
5
-
## 1. Files Must Exist on Disk
5
+
## 1. Files Must Exist on Disk (Handled Automatically)
6
6
7
7
**Limitation**: ty requires Python files to exist on disk before it can provide diagnostics, completion, rename, and other analysis features.
8
8
@@ -11,23 +11,9 @@ This document describes known limitations and behavioral differences when using
11
11
- Empty or limited completion results
12
12
- Rename operations may fail
13
13
14
-
**Workaround**: Always write files to disk before creating a session:
15
-
```python
16
-
from pathlib import Path
14
+
**Resolution**: The `TyBackend` implements `requires_file_on_disk() -> True`, which tells `Session.create()` to automatically write the initial code to disk before opening the document. The `update_code()` method also keeps the file in sync with code changes.
17
15
18
-
base_path = Path("/tmp/my_project")
19
-
base_path.mkdir(exist_ok=True)
20
-
21
-
code ="x: int = 'not an int'"
22
-
(base_path /"new.py").write_text(code)
23
-
24
-
session =await Session.create(
25
-
TyBackend(),
26
-
base_path=base_path,
27
-
initial_code=code,
28
-
)
29
-
diagnostics =await session.get_diagnostics() # Now returns errors
30
-
```
16
+
This is handled transparently - no user action required.
31
17
32
18
## 2. `workspace/didChangeConfiguration` Not Supported
33
19
@@ -82,6 +68,17 @@ WARN Your LSP client doesn't support file watching: You may see stale results wh
82
68
83
69
**Impact**: If files are modified outside the LSP session (e.g., by external tools), ty may not detect the changes until the session is recreated.
84
70
71
+
## 7. Completion Item Resolution Not Supported
72
+
73
+
**Limitation**: ty does not support the `completionItem/resolve` LSP request.
74
+
75
+
**Behavior**: Calling `resolve_completion()` will raise an error:
76
+
```
77
+
Unknown request: completionItem/resolve (-32601)
78
+
```
79
+
80
+
**Impact**: Completion items won't have extended documentation or additional metadata that resolution typically provides. Basic completion works fine.
0 commit comments