@@ -53,6 +53,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
5353 typeof productOrModuleName == "string"
5454 ? productOrModuleName
5555 : translateProductToModule ( productOrModuleName ) ;
56+
5657 const productName =
5758 typeof productOrModuleName === "string"
5859 ? name
@@ -61,8 +62,11 @@ export abstract class ModuleInstaller implements IModuleInstaller {
6162 installer : this . displayName ,
6263 productName,
6364 } ) ;
65+
6466 const uri = isResource ( resource ) ? resource : undefined ;
67+
6568 const options : TerminalCreationOptions = { } ;
69+
6670 if ( isResource ( resource ) ) {
6771 options . resource = uri ;
6872 } else {
@@ -73,35 +77,43 @@ export abstract class ModuleInstaller implements IModuleInstaller {
7377 resource ,
7478 flags ,
7579 ) ;
80+
7681 const terminalService = this . serviceContainer
7782 . get < ITerminalServiceFactory > ( ITerminalServiceFactory )
7883 . getTerminalService ( options ) ;
84+
7985 const install = async ( token ?: CancellationToken ) => {
8086 const executionInfoArgs = await this . processInstallArgs (
8187 executionInfo . args ,
8288 resource ,
8389 ) ;
90+
8491 if ( executionInfo . moduleName ) {
8592 const configService =
8693 this . serviceContainer . get < IConfigurationService > (
8794 IConfigurationService ,
8895 ) ;
96+
8997 const settings = configService . getSettings ( uri ) ;
9098
9199 const interpreterService =
92100 this . serviceContainer . get < IInterpreterService > (
93101 IInterpreterService ,
94102 ) ;
103+
95104 const interpreter = isResource ( resource )
96105 ? await interpreterService . getActiveInterpreter ( resource )
97106 : resource ;
107+
98108 const pythonPath = isResource ( resource )
99109 ? settings . pythonPath
100110 : resource . path ;
111+
101112 const args = internalPython . execModule (
102113 executionInfo . moduleName ,
103114 executionInfoArgs ,
104115 ) ;
116+
105117 if (
106118 ! interpreter ||
107119 interpreter . envType !== EnvironmentType . Unknown
@@ -110,6 +122,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
110122 } else if ( settings . globalModuleInstallation ) {
111123 const fs =
112124 this . serviceContainer . get < IFileSystem > ( IFileSystem ) ;
125+
113126 if (
114127 await fs
115128 . isDirReadonly ( path . dirname ( pythonPath ) )
@@ -148,6 +161,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
148161 if ( cancel ) {
149162 const shell =
150163 this . serviceContainer . get < IApplicationShell > ( IApplicationShell ) ;
164+
151165 const options : ProgressOptions = {
152166 location : ProgressLocation . Notification ,
153167 cancellable : true ,
@@ -168,10 +182,12 @@ export abstract class ModuleInstaller implements IModuleInstaller {
168182 const options = {
169183 name : "VS Code Python" ,
170184 } ;
185+
171186 const outputChannel = this . serviceContainer . get < IOutputChannel > (
172187 IOutputChannel ,
173188 STANDARD_OUTPUT_CHANNEL ,
174189 ) ;
190+
175191 const command = `"${ execPath . replace ( / \\ / g, "/" ) } " ${ args . join ( " " ) } ` ;
176192
177193 traceLog ( `[Elevated] ${ command } ` ) ;
@@ -190,6 +206,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
190206 await shell . showErrorMessage ( error ) ;
191207 } else {
192208 outputChannel . show ( ) ;
209+
193210 if ( stdout ) {
194211 traceLog ( stdout ) ;
195212 }
@@ -212,11 +229,13 @@ export abstract class ModuleInstaller implements IModuleInstaller {
212229 const indexOfPylint = args . findIndex (
213230 ( arg ) => arg . toUpperCase ( ) === "PYLINT" ,
214231 ) ;
232+
215233 if ( indexOfPylint === - 1 ) {
216234 return args ;
217235 }
218236 const interpreterService =
219237 this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
238+
220239 const interpreter = isResource ( resource )
221240 ? await interpreterService . getActiveInterpreter ( resource )
222241 : resource ;
@@ -229,6 +248,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
229248 const newArgs = [ ...args ] ;
230249 // This command could be sent to the terminal, hence '<' needs to be escaped for UNIX.
231250 newArgs [ indexOfPylint ] = '"pylint<2.0.0"' ;
251+
232252 return newArgs ;
233253 }
234254 return args ;
@@ -239,52 +259,76 @@ export function translateProductToModule(product: Product): string {
239259 switch ( product ) {
240260 case Product . mypy :
241261 return "mypy" ;
262+
242263 case Product . pylama :
243264 return "pylama" ;
265+
244266 case Product . prospector :
245267 return "prospector" ;
268+
246269 case Product . pylint :
247270 return "pylint" ;
271+
248272 case Product . pytest :
249273 return "pytest" ;
274+
250275 case Product . autopep8 :
251276 return "autopep8" ;
277+
252278 case Product . black :
253279 return "black" ;
280+
254281 case Product . pycodestyle :
255282 return "pycodestyle" ;
283+
256284 case Product . pydocstyle :
257285 return "pydocstyle" ;
286+
258287 case Product . yapf :
259288 return "yapf" ;
289+
260290 case Product . flake8 :
261291 return "flake8" ;
292+
262293 case Product . unittest :
263294 return "unittest" ;
295+
264296 case Product . bandit :
265297 return "bandit" ;
298+
266299 case Product . jupyter :
267300 return "jupyter" ;
301+
268302 case Product . notebook :
269303 return "notebook" ;
304+
270305 case Product . pandas :
271306 return "pandas" ;
307+
272308 case Product . ipykernel :
273309 return "ipykernel" ;
310+
274311 case Product . nbconvert :
275312 return "nbconvert" ;
313+
276314 case Product . kernelspec :
277315 return "kernelspec" ;
316+
278317 case Product . tensorboard :
279318 return "tensorboard" ;
319+
280320 case Product . torchProfilerInstallName :
281321 return "torch-tb-profiler" ;
322+
282323 case Product . torchProfilerImportName :
283324 return "torch_tb_profiler" ;
325+
284326 case Product . pip :
285327 return "pip" ;
328+
286329 case Product . ensurepip :
287330 return "ensurepip" ;
331+
288332 default : {
289333 throw new Error (
290334 `Product ${ product } cannot be installed as a Python Module.` ,
0 commit comments