Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65f9709

Browse files
authored
Fix linting.pylintEnabled setting check (microsoft#12444)
* Fix `linting.pylintEnabled` setting check * Use stub instead of handspun variable
1 parent 17e317b commit 65f9709

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

news/2 Fixes/12285.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix `linting.pylintEnabled` setting check.

src/client/linters/linterInfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class PylintLinterInfo extends LinterInfo {
9999
// If we're using LS, then by default Pylint is disabled unless user provided
100100
// the value. We have to resort to direct inspection of settings here.
101101
const configuration = this.workspaceService.getConfiguration('python', resource);
102-
const inspection = configuration.inspect<boolean>(this.enabledSettingName);
102+
const inspection = configuration.inspect<boolean>(`linting.${this.enabledSettingName}`);
103103
if (
104104
!inspection ||
105105
(inspection.globalValue === undefined &&

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

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// tslint:disable:chai-vague-errors no-unused-expression max-func-body-length no-any
77

88
import { expect } from 'chai';
9+
import * as sinon from 'sinon';
910
import { anything, instance, mock, when } from 'ts-mockito';
1011
import { LanguageServerType } from '../../client/activation/types';
1112
import { WorkspaceService } from '../../client/common/application/workspace';
@@ -62,6 +63,22 @@ suite('Linter Info - Pylint', () => {
6263

6364
expect(linterInfo.isEnabled()).to.be.false;
6465
});
66+
test('Should inspect the value of linting.pylintEnabled when using Language Server', async () => {
67+
const linterInfo = new PylintLinterInfo(instance(config), instance(workspace), []);
68+
const inspectStub = sinon.stub();
69+
const pythonConfig = {
70+
inspect: inspectStub
71+
};
72+
73+
when(config.getSettings(anything())).thenReturn({
74+
linting: { pylintEnabled: true },
75+
languageServer: LanguageServerType.Microsoft
76+
} as any);
77+
when(workspace.getConfiguration('python', anything())).thenReturn(pythonConfig as any);
78+
79+
expect(linterInfo.isEnabled()).to.be.false;
80+
expect(inspectStub.calledOnceWith('linting.pylintEnabled')).to.be.true;
81+
});
6582
const testsForisEnabled = [
6683
{
6784
testName: 'When workspaceFolder setting is provided',

0 commit comments

Comments
 (0)