From 76642f980250af1fdc0e0d67bdae729916ddb2d6 Mon Sep 17 00:00:00 2001 From: Alexander Pushkov Date: Tue, 11 Jun 2019 18:07:11 +0300 Subject: [PATCH 1/3] if black is being installed, append --allow-prereleases fixes #5756 --- src/client/common/installer/poetryInstaller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 }; } From 710efb0b76b15f706690d6a9b6a10d3aa52f62b0 Mon Sep 17 00:00:00 2001 From: Alexander Pushkov Date: Tue, 11 Jun 2019 18:17:04 +0300 Subject: [PATCH 2/3] update news --- news/2 Fixes/5756.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2 Fixes/5756.md 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. From 551e1002f4853f9394e133fe497d4fdb63318cc1 Mon Sep 17 00:00:00 2001 From: Alexander Pushkov Date: Thu, 20 Jun 2019 13:05:43 +0300 Subject: [PATCH 3/3] add unit test for installing black with poetry --- .../common/installer/poetryInstaller.unit.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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' }); + }); });