diff --git a/news/2 Fixes/5756.md b/news/2 Fixes/5756.md new file mode 100644 index 000000000000..3b0dad7ee161 --- /dev/null +++ b/news/2 Fixes/5756.md @@ -0,0 +1 @@ +Append `--allow-prereleases` to black installation command so pipenv can properly resolve it. diff --git a/src/client/common/installer/poetryInstaller.ts b/src/client/common/installer/poetryInstaller.ts index 75809c11796e..f5b4c5fabfd5 100644 --- a/src/client/common/installer/poetryInstaller.ts +++ b/src/client/common/installer/poetryInstaller.ts @@ -60,8 +60,12 @@ export class PoetryInstaller extends ModuleInstaller implements IModuleInstaller } protected async getExecutionInfo(moduleName: string, resource?: Uri): Promise { const execPath = this.configurationService.getSettings(resource).poetryPath; + const args = ['add', '--dev', moduleName]; + if (moduleName === 'black') { + args.push('--allow-prereleases'); + } return { - args: ['add', '--dev', moduleName], + args, execPath }; } diff --git a/src/test/common/installer/poetryInstaller.unit.test.ts b/src/test/common/installer/poetryInstaller.unit.test.ts index 4517c4da62b3..e4bca8b3420b 100644 --- a/src/test/common/installer/poetryInstaller.unit.test.ts +++ b/src/test/common/installer/poetryInstaller.unit.test.ts @@ -122,4 +122,15 @@ suite('Module Installer - Poetry', () => { assert.deepEqual(info, { args: ['add', '--dev', 'something'], execPath: 'poetry path' }); }); + test('Get executable info when installing black', async () => { + const uri = Uri.file(__dirname); + const settings = mock(PythonSettings); + + when(configurationService.getSettings(uri)).thenReturn(instance(settings)); + when(settings.poetryPath).thenReturn('poetry path'); + + const info = await poetryInstaller.getExecutionInfo('black', uri); + + assert.deepEqual(info, { args: ['add', '--dev', 'black', '--allow-prereleases'], execPath: 'poetry path' }); + }); });