Skip to content

Fix linting.pylintEnabled setting check #12444

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

Merged
merged 2 commits into from
Jun 22, 2020
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
1 change: 1 addition & 0 deletions news/2 Fixes/12285.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `linting.pylintEnabled` setting check.
2 changes: 1 addition & 1 deletion src/client/linters/linterInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class PylintLinterInfo extends LinterInfo {
// If we're using LS, then by default Pylint is disabled unless user provided
// the value. We have to resort to direct inspection of settings here.
const configuration = this.workspaceService.getConfiguration('python', resource);
const inspection = configuration.inspect<boolean>(this.enabledSettingName);
const inspection = configuration.inspect<boolean>(`linting.${this.enabledSettingName}`);
if (
!inspection ||
(inspection.globalValue === undefined &&
Expand Down
17 changes: 17 additions & 0 deletions src/test/linters/linterinfo.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// tslint:disable:chai-vague-errors no-unused-expression max-func-body-length no-any

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

expect(linterInfo.isEnabled()).to.be.false;
});
test('Should inspect the value of linting.pylintEnabled when using Language Server', async () => {
const linterInfo = new PylintLinterInfo(instance(config), instance(workspace), []);
const inspectStub = sinon.stub();
const pythonConfig = {
inspect: inspectStub
};

when(config.getSettings(anything())).thenReturn({
linting: { pylintEnabled: true },
languageServer: LanguageServerType.Microsoft
} as any);
when(workspace.getConfiguration('python', anything())).thenReturn(pythonConfig as any);

expect(linterInfo.isEnabled()).to.be.false;
expect(inspectStub.calledOnceWith('linting.pylintEnabled')).to.be.true;
});
const testsForisEnabled = [
{
testName: 'When workspaceFolder setting is provided',
Expand Down