diff --git a/news/2 Fixes/5087.md b/news/2 Fixes/5087.md new file mode 100644 index 000000000000..1d7f1f9dd4fb --- /dev/null +++ b/news/2 Fixes/5087.md @@ -0,0 +1 @@ +No prompt displayed to install pylint diff --git a/src/client/linters/linterInfo.ts b/src/client/linters/linterInfo.ts index 1028f0c4ec42..566db9ab59da 100644 --- a/src/client/linters/linterInfo.ts +++ b/src/client/linters/linterInfo.ts @@ -82,7 +82,7 @@ export class PylintLinterInfo extends LinterInfo { } // If we're using new LS, then by default Pylint is disabled (unless the user provides a value). const inspection = this.workspaceService.getConfiguration('python', resource).inspect('linting.pylintEnabled'); - if (!inspection || (inspection.globalValue === undefined && (inspection.workspaceFolderValue === undefined || inspection.workspaceValue === undefined))) { + if (!inspection || (inspection.globalValue === undefined && (inspection.workspaceFolderValue === undefined && inspection.workspaceValue === undefined))) { return false; } return enabled; diff --git a/src/test/linters/linterinfo.unit.test.ts b/src/test/linters/linterinfo.unit.test.ts index 1784a7b61842..ed3522ce004f 100644 --- a/src/test/linters/linterinfo.unit.test.ts +++ b/src/test/linters/linterinfo.unit.test.ts @@ -53,22 +53,37 @@ suite('Linter Info - Pylint', () => { expect(linterInfo.isEnabled()).to.be.false; }); - test('Test enabled when using Language Server and Pylint is configured', async () => { - const config = mock(ConfigurationService); - const workspaceService = mock(WorkspaceService); - const linterInfo = new PylintLinterInfo(instance(config), instance(workspaceService), []); + const testsForisEnabled = + [ + { + testName: 'When workspaceFolder setting is provided', + inspection: { workspaceFolderValue: true } + }, + { + testName: 'When workspace setting is provided', + inspection: { workspaceValue: true } + }, + { + testName: 'When global setting is provided', + inspection: { globalValue: true } + } + ]; - const inspection = { - globalValue: 'something', - workspaceFolderValue: 'something', - workspaceValue: 'something' - }; - const pythonConfig = { - inspect: () => inspection - }; - when(config.getSettings(anything())).thenReturn({ linting: { pylintEnabled: true }, jediEnabled: false } as any); - when(workspaceService.getConfiguration('python', anything())).thenReturn(pythonConfig as any); + suite('Test is enabled when using Language Server and Pylint is configured', () => { + testsForisEnabled.forEach(testParams => { + test(testParams.testName, async () => { + const config = mock(ConfigurationService); + const workspaceService = mock(WorkspaceService); + const linterInfo = new PylintLinterInfo(instance(config), instance(workspaceService), []); - expect(linterInfo.isEnabled()).to.be.true; + const pythonConfig = { + inspect: () => testParams.inspection + }; + when(config.getSettings(anything())).thenReturn({ linting: { pylintEnabled: true }, jediEnabled: false } as any); + when(workspaceService.getConfiguration('python', anything())).thenReturn(pythonConfig as any); + + expect(linterInfo.isEnabled()).to.be.true; + }); + }); }); });