Skip to content

Commit b29e964

Browse files
author
Kartik Raj
committed
Use env type to figure out type information
1 parent 04151b4 commit b29e964

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/client/proposedApi.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import {
1919
Resource,
2020
RefreshStateValue,
2121
RefreshState,
22+
EnvironmentType,
2223
} from './proposedApiTypes';
23-
import { PythonEnvInfo, PythonEnvKind, virtualEnvKinds } from './pythonEnvironments/base/info';
24+
import { PythonEnvInfo, PythonEnvKind, PythonEnvType, virtualEnvKinds } from './pythonEnvironments/base/info';
2425
import { getEnvPath } from './pythonEnvironments/base/info/env';
2526
import { IDiscoveryAPI, ProgressReportStage } from './pythonEnvironments/base/locator';
2627

@@ -167,9 +168,9 @@ export function convertCompleteEnvInfo(env: PythonEnvInfo): ResolvedEnvironment
167168
bitness: convertArch(env.arch),
168169
sysPrefix: env.executable.sysPrefix,
169170
},
170-
environment: virtualEnvKinds.includes(env.kind)
171+
environment: env.type
171172
? {
172-
type: env.kind === PythonEnvKind.Conda ? 'Conda' : 'VirtualEnv',
173+
type: convertEnvType(env.type),
173174
name: env.name,
174175
folderUri: Uri.file(env.location),
175176
workspaceFolder: env.searchLocation,
@@ -181,6 +182,16 @@ export function convertCompleteEnvInfo(env: PythonEnvInfo): ResolvedEnvironment
181182
return resolvedEnv;
182183
}
183184

185+
function convertEnvType(envType: PythonEnvType): EnvironmentType {
186+
if (envType === PythonEnvType.Conda) {
187+
return 'Conda';
188+
}
189+
if (envType === PythonEnvType.Virtual) {
190+
return 'VirtualEnv';
191+
}
192+
return 'Unknown';
193+
}
194+
184195
function convertEnvInfoAndGetReference(env: PythonEnvInfo): Environment {
185196
const convertedEnv = convertCompleteEnvInfo(env) as Environment;
186197
if (convertedEnv.executable.sysPrefix === '') {

0 commit comments

Comments
 (0)