Skip to content

Commit 2d8bc7e

Browse files
committed
Document per-file interpreter resolution in the config middleware
Clarify why the workspace/configuration handler resolves the interpreter for the exact .py file (exactResource) rather than its folder: it honors a per-file environment such as a PEP 723 inline-script env for the language client this extension hosts, and only diverges from folder resolution when the Python Environments extension is in use. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e413c74 commit 2d8bc7e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/client/activation/languageClientMiddlewareBase.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ export class LanguageClientMiddlewareBase implements Middleware {
8787
const settingDict: LSPObject & { pythonPath: string; _envPYTHONPATH: string } = settings[
8888
i
8989
] as LSPObject & { pythonPath: string; _envPYTHONPATH: string };
90+
// For a .py file resource, resolve the interpreter for that exact file rather than its
91+
// containing workspace folder, so a per-file environment (such as a PEP 723 inline-script
92+
// environment created for a single script) is honored for the language client hosted by
93+
// this extension. This only diverges from workspace-folder resolution when the Python
94+
// Environments extension is in use; otherwise getActiveInterpreter ignores exactResource.
9095
const exactResource = uri && path.extname(uri.fsPath).toLowerCase() === '.py';
9196
settingDict.pythonPath =
9297
(

0 commit comments

Comments
 (0)