Skip to content

Commit d4b208e

Browse files
Mazyodclaude
andcommitted
fix: use bare paths for basedpyright initializationOptions.files keys
The browser-basedpyright worker expects bare filesystem paths (e.g. /src/main.py) for its in-memory VFS, not file:// URIs. Also adds typeshedPath to config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f938a40 commit d4b208e

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

playground/src/backends/pyright.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ const PACKAGE = "browser-basedpyright";
1919
const VERSION = "1.28.1";
2020
const WORKER_URL = `https://cdn.jsdelivr.net/npm/${PACKAGE}@${VERSION}/dist/pyright.worker.js`;
2121

22-
const FILE_URI = "file:///src/main.py";
23-
const CONFIG_URI = "file:///src/pyrightconfig.json";
22+
const ROOT_PATH = "/src/";
23+
const ROOT_URI = `file://${ROOT_PATH}`;
24+
const FILE_NAME = "main.py";
25+
const FILE_PATH = `${ROOT_PATH}${FILE_NAME}`;
26+
const FILE_URI = `${ROOT_URI}${FILE_NAME}`;
27+
const CONFIG_PATH = `${ROOT_PATH}pyrightconfig.json`;
2428

2529
const DEFAULT_CONFIG = JSON.stringify({
30+
typeshedPath: "/typeshed",
2631
pythonVersion: "3.12",
2732
typeCheckingMode: "standard",
2833
});
@@ -96,9 +101,10 @@ export class PyrightBackend implements BackendAdapter {
96101
this.connection.listen();
97102

98103
// LSP initialize handshake
104+
// Note: initializationOptions.files uses bare paths (not file:// URIs)
99105
await this.connection.sendRequest("initialize", {
100-
rootUri: "file:///src/",
101-
rootPath: "/src/",
106+
rootUri: ROOT_URI,
107+
rootPath: ROOT_PATH,
102108
processId: 1,
103109
capabilities: {
104110
textDocument: {
@@ -113,8 +119,8 @@ export class PyrightBackend implements BackendAdapter {
113119
},
114120
initializationOptions: {
115121
files: {
116-
[FILE_URI]: "",
117-
[CONFIG_URI]: DEFAULT_CONFIG,
122+
[FILE_PATH]: "",
123+
[CONFIG_PATH]: DEFAULT_CONFIG,
118124
},
119125
},
120126
});

0 commit comments

Comments
 (0)