Conversation
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/5f628821-9c7b-48a6-9f5f-9fccb9a33bf6 Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/5f628821-9c7b-48a6-9f5f-9fccb9a33bf6 Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/5f628821-9c7b-48a6-9f5f-9fccb9a33bf6 Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/5f628821-9c7b-48a6-9f5f-9fccb9a33bf6 Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/5f628821-9c7b-48a6-9f5f-9fccb9a33bf6 Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/5f628821-9c7b-48a6-9f5f-9fccb9a33bf6 Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/ee61d4e1-336b-405a-93dc-f691bd210c7e Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds UV-mode coverage for run-button task execution, ensuring that when python-envs.alwaysUseUv applies the task is executed via uv run --python <interpreter> ..., and that the setting is resolved with proper project/workspace scope precedence.
Changes:
- Updated
runAsTask()to route task execution throughuv run --python ...whenshouldUseUv()applies (including passing project URI scope for settings precedence). - Extended
shouldUseUv()to accept an optional VS Code configuration scope for correct workspace-folder precedence. - Added/expanded unit tests covering UV/non-UV execution paths, quoting behavior for the UV executable, and scope passing.
Show a summary per file
| File | Description |
|---|---|
| src/test/features/execution/runAsTask.unit.test.ts | Adds unit test coverage for UV-mode task invocation, scope passing, and argument ordering. |
| src/managers/builtin/helpers.ts | Extends shouldUseUv() with an optional ConfigurationScope to respect settings precedence. |
| src/features/execution/runAsTask.ts | Implements UV-mode task execution (uv run --python ...) and passes project URI scope to shouldUseUv(). |
| package.nls.json | Updates the alwaysUseUv setting description to mention run-button behavior. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
|
this PR needs to updated to better respect PEP 723 style scripts: Run Button: Interpreter Selection Logic PEP 723 script (/// script block present): Run with uv run <script> and let uv manage interpreter and dependency resolution entirely. The script is self-contained and declares its own requirements, so the user's saved interpreter is not relevant. Detection is done by scanning the script file for the /// script marker before constructing the run command. |
- Strip surrounding quotes from executable before passing as --python to uv; quoting the argument value causes uv to fail to resolve the interpreter (mirrors the same fix in runInBackground.ts) - Add regression test: quoted python path under uv mode is unquoted - Update shouldUseUv JSDoc to document the new scope parameter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When the run button is clicked on a PEP 723 script (one containing a `# /// script` block), uv manages the interpreter and dependencies entirely. We must not pass `--python` in that case or it would override the script's own requirements. Detection logic: - New `isPep723Script(filePath)` helper in pep723.ts reads the script and checks for the PEP 723 opening marker `# /// script` - In runAsTask, when uv mode is active, inspect options.args[0] (the script path) before building the command: `uv run <script> [userArgs]` (no --python, no env args) `uv run --python <interpreter> [envArgs] [userArgs]` Tests added: - pep723.unit.test.ts: unit tests for isPep723Script (marker present, absent, near-misses, trailing whitespace, read error fallback) - runAsTask.unit.test.ts: PEP 723 suite (uv run without --python, extra user args forwarded, flag-first args skip detection, non-PEP 723 still gets --python, read-error graceful fallback) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…wrapper
TypeScript's __importStar wraps CommonJS modules in a new object where
every property is a non-configurable sinon cannot stub them.getter
Stub the underlying require('fs-extra') object instead; the namespace
wrapper's getters delegate to it, so the stub is picked up by the
source-under-test transparently. All 7 pep723 tests now pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.