Skip to content

Commit b9a86b0

Browse files
author
Kartik Raj
authored
Ensure prompt is displayed to install pylint when user has configured pylint (microsoft#5356)
* Corrected bug and added tests * News entry
1 parent 414ac48 commit b9a86b0

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

news/2 Fixes/5087.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No prompt displayed to install pylint

src/client/linters/linterInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class PylintLinterInfo extends LinterInfo {
8282
}
8383
// If we're using new LS, then by default Pylint is disabled (unless the user provides a value).
8484
const inspection = this.workspaceService.getConfiguration('python', resource).inspect<boolean>('linting.pylintEnabled');
85-
if (!inspection || (inspection.globalValue === undefined && (inspection.workspaceFolderValue === undefined || inspection.workspaceValue === undefined))) {
85+
if (!inspection || (inspection.globalValue === undefined && (inspection.workspaceFolderValue === undefined && inspection.workspaceValue === undefined))) {
8686
return false;
8787
}
8888
return enabled;

src/test/linters/linterinfo.unit.test.ts

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,37 @@ suite('Linter Info - Pylint', () => {
5353

5454
expect(linterInfo.isEnabled()).to.be.false;
5555
});
56-
test('Test enabled when using Language Server and Pylint is configured', async () => {
57-
const config = mock(ConfigurationService);
58-
const workspaceService = mock(WorkspaceService);
59-
const linterInfo = new PylintLinterInfo(instance(config), instance(workspaceService), []);
56+
const testsForisEnabled =
57+
[
58+
{
59+
testName: 'When workspaceFolder setting is provided',
60+
inspection: { workspaceFolderValue: true }
61+
},
62+
{
63+
testName: 'When workspace setting is provided',
64+
inspection: { workspaceValue: true }
65+
},
66+
{
67+
testName: 'When global setting is provided',
68+
inspection: { globalValue: true }
69+
}
70+
];
6071

61-
const inspection = {
62-
globalValue: 'something',
63-
workspaceFolderValue: 'something',
64-
workspaceValue: 'something'
65-
};
66-
const pythonConfig = {
67-
inspect: () => inspection
68-
};
69-
when(config.getSettings(anything())).thenReturn({ linting: { pylintEnabled: true }, jediEnabled: false } as any);
70-
when(workspaceService.getConfiguration('python', anything())).thenReturn(pythonConfig as any);
72+
suite('Test is enabled when using Language Server and Pylint is configured', () => {
73+
testsForisEnabled.forEach(testParams => {
74+
test(testParams.testName, async () => {
75+
const config = mock(ConfigurationService);
76+
const workspaceService = mock(WorkspaceService);
77+
const linterInfo = new PylintLinterInfo(instance(config), instance(workspaceService), []);
7178

72-
expect(linterInfo.isEnabled()).to.be.true;
79+
const pythonConfig = {
80+
inspect: () => testParams.inspection
81+
};
82+
when(config.getSettings(anything())).thenReturn({ linting: { pylintEnabled: true }, jediEnabled: false } as any);
83+
when(workspaceService.getConfiguration('python', anything())).thenReturn(pythonConfig as any);
84+
85+
expect(linterInfo.isEnabled()).to.be.true;
86+
});
87+
});
7388
});
7489
});

0 commit comments

Comments
 (0)