Switch to directly invoke python-environments-ext api#849
Merged
eleanorjboyd merged 13 commits intomicrosoft:mainfrom Nov 3, 2025
Merged
Switch to directly invoke python-environments-ext api#849eleanorjboyd merged 13 commits intomicrosoft:mainfrom
eleanorjboyd merged 13 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors Python environment handling to support both the legacy Python extension API and a new Python Environments extension API. The changes enable runtime selection between the two APIs based on a configuration setting and extension availability.
Key Changes:
- Introduced a new
envExtApi.tsmodule containing the complete Python Environments extension API type definitions - Refactored
python.tsto conditionally use either the legacy or new environment API viauseEnvExtension()flag - Extracted legacy API implementation into
legacyPython.tsfor cleaner separation - Updated test suites to accommodate both API paths with new helper utilities
- Modified debug adapter factory and configuration resolvers to work with the new
PythonEnvironmenttype
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/extension/envExtApi.ts |
Added comprehensive API type definitions for the new Python Environments extension (1289 lines) |
src/extension/common/python.ts |
Refactored to support dual API paths with conditional logic based on useEnvExtension() |
src/extension/common/legacyPython.ts |
Extracted legacy Python extension API implementation from python.ts |
src/extension/common/utilities.ts |
Added useEnvExtension() function to determine which API to use at runtime |
src/extension/debugger/adapter/factory.ts |
Updated to use new PythonEnvironment type and added version parsing logic |
src/extension/debugger/configuration/resolvers/base.ts |
Enhanced to resolve interpreter from program file when appropriate |
src/extension/debugger/configuration/debugConfigurationService.ts |
Added interpreter resolution after variable substitution |
src/extension/common/application/commands/reportIssueCommand.ts |
Updated to handle both environment API return types |
src/test/unittest/common/pythonTrue.unit.test.ts |
New test suite for new environment extension path |
src/test/unittest/common/pythonFalse.unit.test.ts |
New test suite for legacy extension path |
src/test/unittest/common/helpers.ts |
Added buildPythonEnvironment() test helper function |
src/test/unittest/adapter/factory.unit.test.ts |
Updated tests to use new PythonEnvironment type |
src/test/unittest/configuration/resolvers/launch.unit.test.ts |
Updated to handle both API return types |
src/test/unittest/common/application/commands/reportIssueCommand.unit.test.ts |
Updated mock interpreter structure |
Comments suppressed due to low confidence (1)
src/test/unittest/common/pythonFalse.unit.test.ts:4
- This expression has no effect.
('use strict');
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/extension/common/application/commands/reportIssueCommand.ts
Outdated
Show resolved
Hide resolved
karthiknadig
approved these changes
Nov 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
switch from using the Python extension apis to get the interpreter to instead using the Python Environments extension APIs (when available) as this will be the new best practice
closes #835