Skip to content

Commit e47871f

Browse files
committed
edits
1 parent e4cb306 commit e47871f

2 files changed

Lines changed: 33 additions & 42 deletions

File tree

src/common/pickers/environments.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ export async function pickEnvironment(
157157
];
158158

159159
if (options?.recommended) {
160-
// Include interpreter path in description for recommended environment too
161160
const pathDescription = options.recommended.displayPath;
162-
const description = options.recommended.description && options.recommended.description.trim()
163-
? `${options.recommended.description} (${pathDescription})`
164-
: pathDescription;
165-
161+
const description =
162+
options.recommended.description && options.recommended.description.trim()
163+
? `${options.recommended.description} (${pathDescription})`
164+
: pathDescription;
165+
166166
items.push(
167167
{
168168
label: Common.recommended,
@@ -185,12 +185,10 @@ export async function pickEnvironment(
185185
const envs = await manager.getEnvironments('all');
186186
items.push(
187187
...envs.map((e) => {
188-
// Include interpreter path in description. If original description exists and is not empty, append path to it.
189188
const pathDescription = e.displayPath;
190-
const description = e.description && e.description.trim()
191-
? `${e.description} (${pathDescription})`
192-
: pathDescription;
193-
189+
const description =
190+
e.description && e.description.trim() ? `${e.description} (${pathDescription})` : pathDescription;
191+
194192
return {
195193
label: e.displayName ?? e.name,
196194
description: description,
@@ -207,12 +205,10 @@ export async function pickEnvironment(
207205

208206
export async function pickEnvironmentFrom(environments: PythonEnvironment[]): Promise<PythonEnvironment | undefined> {
209207
const items = environments.map((e) => {
210-
// Include interpreter path in description. If original description exists and is not empty, append path to it.
211208
const pathDescription = e.displayPath;
212-
const description = e.description && e.description.trim()
213-
? `${e.description} (${pathDescription})`
214-
: pathDescription;
215-
209+
const description =
210+
e.description && e.description.trim() ? `${e.description} (${pathDescription})` : pathDescription;
211+
216212
return {
217213
label: e.displayName ?? e.name,
218214
description: description,

src/test/common/environmentPicker.unit.test.ts

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,65 +28,60 @@ suite('Environment Picker Description Logic', () => {
2828
suite('Description formatting with interpreter path', () => {
2929
test('should use displayPath as description when no original description exists', () => {
3030
const env = createMockEnvironment('/usr/local/bin/python');
31-
31+
3232
// This is the logic from our updated picker
3333
const pathDescription = env.displayPath;
34-
const description = env.description && env.description.trim()
35-
? `${env.description} (${pathDescription})`
36-
: pathDescription;
37-
34+
const description =
35+
env.description && env.description.trim() ? `${env.description} (${pathDescription})` : pathDescription;
36+
3837
assert.strictEqual(description, '/usr/local/bin/python');
3938
});
4039

4140
test('should append displayPath to existing description in parentheses', () => {
4241
const env = createMockEnvironment('/home/user/.venv/bin/python', 'Virtual Environment');
43-
42+
4443
// This is the logic from our updated picker
4544
const pathDescription = env.displayPath;
46-
const description = env.description && env.description.trim()
47-
? `${env.description} (${pathDescription})`
48-
: pathDescription;
49-
45+
const description =
46+
env.description && env.description.trim() ? `${env.description} (${pathDescription})` : pathDescription;
47+
5048
assert.strictEqual(description, 'Virtual Environment (/home/user/.venv/bin/python)');
5149
});
5250

5351
test('should handle complex paths correctly', () => {
5452
const complexPath = '/usr/local/anaconda3/envs/my-project-env/bin/python';
5553
const env = createMockEnvironment(complexPath, 'Conda Environment');
56-
54+
5755
// This is the logic from our updated picker
5856
const pathDescription = env.displayPath;
59-
const description = env.description && env.description.trim()
60-
? `${env.description} (${pathDescription})`
61-
: pathDescription;
62-
57+
const description =
58+
env.description && env.description.trim() ? `${env.description} (${pathDescription})` : pathDescription;
59+
6360
assert.strictEqual(description, `Conda Environment (${complexPath})`);
6461
});
6562

6663
test('should handle empty description correctly', () => {
6764
const env = createMockEnvironment('/opt/python/bin/python', '');
68-
69-
// This is the logic from our updated picker
65+
66+
// This is the logic from our updated picker
7067
const pathDescription = env.displayPath;
71-
const description = env.description && env.description.trim()
72-
? `${env.description} (${pathDescription})`
73-
: pathDescription;
74-
68+
const description =
69+
env.description && env.description.trim() ? `${env.description} (${pathDescription})` : pathDescription;
70+
7571
// Empty string should be treated like no description, so just use path
7672
assert.strictEqual(description, '/opt/python/bin/python');
7773
});
7874

7975
test('should handle Windows paths correctly', () => {
8076
const windowsPath = 'C:\\Python39\\python.exe';
8177
const env = createMockEnvironment(windowsPath, 'System Python');
82-
78+
8379
// This is the logic from our updated picker
8480
const pathDescription = env.displayPath;
85-
const description = env.description && env.description.trim()
86-
? `${env.description} (${pathDescription})`
87-
: pathDescription;
88-
81+
const description =
82+
env.description && env.description.trim() ? `${env.description} (${pathDescription})` : pathDescription;
83+
8984
assert.strictEqual(description, 'System Python (C:\\Python39\\python.exe)');
9085
});
9186
});
92-
});
87+
});

0 commit comments

Comments
 (0)