Add basic Poetry environment lifecycle support - #1700
Eduardo Villalpando Mello (edvilme) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b2fe9b5-38ea-442f-b07a-b6c71134d480
There was a problem hiding this comment.
Pull request overview
Adds basic Poetry environment creation and removal for existing Python projects.
Changes:
- Creates Poetry environments using global Python 3 interpreters.
- Removes environments and clears cached selections.
- Adds localized lifecycle messages and unit coverage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/managers/poetry/poetryManager.ts |
Implements Poetry lifecycle operations. |
src/managers/poetry/main.ts |
Supplies the output channel. |
src/common/localize.ts |
Adds lifecycle messages. |
src/test/managers/poetry/poetryManager.createRemove.unit.test.ts |
Tests creation and removal flows. |
Suppressed comments (1)
src/managers/poetry/poetryManager.ts:208
- After deleting the project mapping,
get(root)falls back toglobalEnv, but this event always reportsnew: undefined. When a different global Poetry environment exists, listeners receive a selection that disagrees with the manager's actual result. Report that fallback, except when the global environment is the one being removed.
new: undefined,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| this._onDidChangeEnvironment.fire({ | ||
| uri: projectRoot, | ||
| old: previousEnvironment, | ||
| new: environment, | ||
| }); |
There was a problem hiding this comment.
Gated both _onDidChangeEnvironment.fire calls: create() now only fires when previousEnvironment?.envId.id !== environment.envId.id, and remove() only fires when there was actually a previous mapping for that project root. Addressed in 91628e9.
| const environments = await this.api.getEnvironments('global'); | ||
| const baseEnvironment = getLatest( | ||
| environments.filter( |
There was a problem hiding this comment.
Switched getBaseEnvironment() to read api.getEnvironment(undefined) and validate that the user's selected global interpreter is Python 3, has a run executable, and isn't itself a Poetry environment. Falls back to the noPython error otherwise, so the user's selection is honored instead of picking the highest global. Addressed in 91628e9.
| if (scope === 'global' || (Array.isArray(scope) && scope.length !== 1)) { | ||
| throw new Error(PoetryStrings.create.singleProject); |
There was a problem hiding this comment.
Handled the global scope in the manager: getCreateProjectRoot() now distinguishes 'global' / empty-array scopes from the multi-project case and throws a dedicated, localized globalNotSupported message so the user sees a clear reason when Poetry is picked from the global creation flow, instead of the misleading "one project at a time" error. A scope-aware API-level filter is a bigger change that's out of scope for this PR. Addressed in 91628e9.
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Summary
Validation