@@ -58,6 +58,18 @@ import { WorkspaceVirtualEnvWatcherService } from './discovery/locators/services
58
58
import { EnvironmentType , PythonEnvironment } from './info' ;
59
59
import { EnvironmentInfoService , IEnvironmentInfoService } from './info/environmentInfoService' ;
60
60
61
+ const convertedKinds = new Map ( Object . entries ( {
62
+ [ PythonEnvKind . System ] : EnvironmentType . System ,
63
+ [ PythonEnvKind . MacDefault ] : EnvironmentType . System ,
64
+ [ PythonEnvKind . WindowsStore ] : EnvironmentType . WindowsStore ,
65
+ [ PythonEnvKind . Pyenv ] : EnvironmentType . Pyenv ,
66
+ [ PythonEnvKind . Conda ] : EnvironmentType . Conda ,
67
+ [ PythonEnvKind . CondaBase ] : EnvironmentType . Conda ,
68
+ [ PythonEnvKind . VirtualEnv ] : EnvironmentType . VirtualEnv ,
69
+ [ PythonEnvKind . Pipenv ] : EnvironmentType . Pipenv ,
70
+ [ PythonEnvKind . Venv ] : EnvironmentType . Venv ,
71
+ } ) ) ;
72
+
61
73
function convertEnvInfo ( info : PythonEnvInfo ) : PythonEnvironment {
62
74
const {
63
75
name,
@@ -79,29 +91,17 @@ function convertEnvInfo(info: PythonEnvInfo): PythonEnvironment {
79
91
architecture : arch ,
80
92
} ;
81
93
82
- if ( kind === PythonEnvKind . System ) {
83
- env . envType = EnvironmentType . System ;
84
- } else if ( kind === PythonEnvKind . MacDefault ) {
85
- env . envType = EnvironmentType . System ;
86
- } else if ( kind === PythonEnvKind . WindowsStore ) {
87
- env . envType = EnvironmentType . WindowsStore ;
88
- } else if ( kind === PythonEnvKind . Pyenv ) {
89
- env . envType = EnvironmentType . Pyenv ;
90
- } else if ( kind === PythonEnvKind . Conda ) {
91
- env . envType = EnvironmentType . Conda ;
92
- } else if ( kind === PythonEnvKind . CondaBase ) {
93
- env . envType = EnvironmentType . Conda ;
94
- } else if ( kind === PythonEnvKind . VirtualEnv ) {
95
- env . envType = EnvironmentType . VirtualEnv ;
96
- } else if ( kind === PythonEnvKind . Pipenv ) {
97
- env . envType = EnvironmentType . Pipenv ;
98
- if ( searchLocation !== undefined ) {
94
+ const envType = convertedKinds . get ( kind ) ;
95
+ if ( envType !== undefined ) {
96
+ env . envType = envType ;
97
+ }
98
+ // Otherwise it stays Unknown.
99
+
100
+ if ( searchLocation !== undefined ) {
101
+ if ( kind === PythonEnvKind . Pipenv ) {
99
102
env . pipEnvWorkspaceFolder = searchLocation . fsPath ;
100
103
}
101
- } else if ( kind === PythonEnvKind . Venv ) {
102
- env . envType = EnvironmentType . Venv ;
103
104
}
104
- // Otherwise it stays Unknown.
105
105
106
106
if ( version !== undefined ) {
107
107
const { release, sysVersion } = version ;
0 commit comments