See “Layer 3” comment here: microsoft/vscode-python-environments#1491 (comment)
When you pick an env via [vscode-python-environments (VPE)]’ tree, we fire pythonEnvsApi.onDidChangeEnvironment (per-workspace). Both ruff-vscode and ty-vscode subscribe only to the legacy api.environments.onDidChangeActiveEnvironmentPath (global only), so they miss our selections — which is exactly why your Select Interpreter workaround "fixes" it (it sets the global env and fires the legacy event). Pylance already supports both APIs: it dual-subscribes, prefers ours when our extension is installed, falls back to the legacy event otherwise. We think that's the right model for ruff/ty too.
IDK how they do it (probably buried in some proprietary pylance code) but I can think of one optimal way:
- check if the
ms-python.vscode-python-envs extension API can be accessed, if not, load the ms-python.python extension
- subscribe to the loaded extensions’ event
- subscribe to the extension change event, and when either extension gets disabled, goto 1.
related: #479, astral-sh/ty-vscode#293
See “Layer 3” comment here: microsoft/vscode-python-environments#1491 (comment)
IDK how they do it (probably buried in some proprietary pylance code) but I can think of one optimal way:
ms-python.vscode-python-envsextension API can be accessed, if not, load thems-python.pythonextensionrelated: #479, astral-sh/ty-vscode#293