Skip to content

Commit 16899f6

Browse files
notpushkinkimadeline
authored andcommitted
Append --allow-prereleases to black installation command when Poetry is used (#5967)
* if black is being installed, append --allow-prereleases, fixes #5756 * update news * add unit test for installing black with poetry
1 parent 7dc95dc commit 16899f6

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

news/2 Fixes/5756.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Append `--allow-prereleases` to black installation command so pipenv can properly resolve it.

src/client/common/installer/poetryInstaller.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ export class PoetryInstaller extends ModuleInstaller implements IModuleInstaller
6060
}
6161
protected async getExecutionInfo(moduleName: string, resource?: Uri): Promise<ExecutionInfo> {
6262
const execPath = this.configurationService.getSettings(resource).poetryPath;
63+
const args = ['add', '--dev', moduleName];
64+
if (moduleName === 'black') {
65+
args.push('--allow-prereleases');
66+
}
6367
return {
64-
args: ['add', '--dev', moduleName],
68+
args,
6569
execPath
6670
};
6771
}

src/test/common/installer/poetryInstaller.unit.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,15 @@ suite('Module Installer - Poetry', () => {
122122

123123
assert.deepEqual(info, { args: ['add', '--dev', 'something'], execPath: 'poetry path' });
124124
});
125+
test('Get executable info when installing black', async () => {
126+
const uri = Uri.file(__dirname);
127+
const settings = mock(PythonSettings);
128+
129+
when(configurationService.getSettings(uri)).thenReturn(instance(settings));
130+
when(settings.poetryPath).thenReturn('poetry path');
131+
132+
const info = await poetryInstaller.getExecutionInfo('black', uri);
133+
134+
assert.deepEqual(info, { args: ['add', '--dev', 'black', '--allow-prereleases'], execPath: 'poetry path' });
135+
});
125136
});

0 commit comments

Comments
 (0)