Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not special case python.pythonPath setting in config service #18251

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/client/common/configuration/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class ConfigurationService implements IConfigurationService {
resource?: Uri,
configTarget?: ConfigurationTarget,
): Promise<void> {
const interpreterPathService = this.serviceContainer.get<IInterpreterPathService>(IInterpreterPathService);
const defaultSetting = {
uri: resource,
target: configTarget || ConfigurationTarget.WorkspaceFolder,
Expand All @@ -52,10 +51,7 @@ export class ConfigurationService implements IConfigurationService {
configTarget = configTarget || settingsInfo.target;

const configSection = this.workspaceService.getConfiguration(section, settingsInfo.uri);
const currentValue =
section === 'python' && setting === 'pythonPath'
? interpreterPathService.inspect(settingsInfo.uri)
: configSection.inspect(setting);
const currentValue = configSection.inspect(setting);

if (
currentValue !== undefined &&
Expand All @@ -65,13 +61,8 @@ export class ConfigurationService implements IConfigurationService {
) {
return;
}
if (section === 'python' && setting === 'pythonPath') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await interpreterPathService.update(settingsInfo.uri, configTarget, value as any);
} else {
await configSection.update(setting, value, configTarget);
await this.verifySetting(configSection, configTarget, setting, value);
}
await configSection.update(setting, value, configTarget);
await this.verifySetting(configSection, configTarget, setting, value);
}

public async updateSetting(
Expand Down
20 changes: 0 additions & 20 deletions src/test/common/configuration/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,4 @@ suite('Configuration Service', () => {

workspaceConfig.verifyAll();
});

test('If in Deprecate PythonPath experiment & setting to update is `python.pythonPath`, update settings using new API if stored value is not equal to the new value', async () => {
interpreterPathService
.setup((w) => w.inspect(resource))

.returns(() => ({ workspaceFolderValue: 'workspaceFolderValue', key: 'setting' }));
interpreterPathService
.setup((w) => w.update(resource, ConfigurationTarget.WorkspaceFolder, 'newWorkspaceFolderValue'))
.returns(() => Promise.resolve())
.verifiable(TypeMoq.Times.once());

await configService.updateSetting(
'pythonPath',
'newWorkspaceFolderValue',
resource,
ConfigurationTarget.WorkspaceFolder,
);

interpreterPathService.verifyAll();
});
});