Skip to content

Commit e2218b1

Browse files
authored
Remove setting linting.lintOnTextChange as it was never implemented (#315)
Fixes #313 The setting linting.lintOnTextChange is deprecated as it was never implemented.
1 parent c1edd58 commit e2218b1

File tree

6 files changed

+31
-30
lines changed

6 files changed

+31
-30
lines changed

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ const hygiene = exports.hygiene = (some, options) => {
180180
}
181181
};
182182
}
183-
const tsProject = ts.createProject('tsconfig.json', { strict: true, noImplicitAny: false });
183+
const tsProject = ts.createProject('tsconfig.json', { strict: true, noImplicitAny: false, noImplicitThis: false });
184184
const reporter = customReporter();
185185
return tsProject(reporter);
186186
}
@@ -231,7 +231,7 @@ function run(lintOnlyModifiedFiles, doNotExit) {
231231
if (lintOnlyModifiedFiles && doNotExit) {
232232
console.log('Watching for changes...');
233233
}
234-
}
234+
}
235235
process.on('unhandledRejection', (reason, p) => {
236236
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
237237
exitProcessOnError();

package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -957,12 +957,6 @@
957957
"description": "Whether to lint Python files using mypy.",
958958
"scope": "resource"
959959
},
960-
"python.linting.lintOnTextChange": {
961-
"type": "boolean",
962-
"default": true,
963-
"description": "Whether to lint Python files when modified.",
964-
"scope": "resource"
965-
},
966960
"python.linting.lintOnSave": {
967961
"type": "boolean",
968962
"default": true,

src/client/common/configSettings.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export interface ILintingSettings {
8484
flake8Args: string[];
8585
pydocstyleEnabled: boolean;
8686
pydocstyleArgs: string[];
87-
lintOnTextChange: boolean;
8887
lintOnSave: boolean;
8988
maxNumberOfProblems: number;
9089
pylintCategorySeverity: IPylintCategorySeverity;
@@ -242,7 +241,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
242241
enabledWithoutWorkspace: false,
243242
ignorePatterns: [],
244243
flake8Args: [], flake8Enabled: false, flake8Path: 'flake',
245-
lintOnSave: false, lintOnTextChange: false, maxNumberOfProblems: 100,
244+
lintOnSave: false, maxNumberOfProblems: 100,
246245
mypyArgs: [], mypyEnabled: false, mypyPath: 'mypy',
247246
outputWindow: 'python', pep8Args: [], pep8Enabled: false, pep8Path: 'pep8',
248247
pylamaArgs: [], pylamaEnabled: false, pylamaPath: 'pylama',

src/client/common/featureDeprecationManager.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { commands, Disposable, window, workspace } from 'vscode';
4+
import { commands, Disposable, window, workspace, WorkspaceConfiguration } from 'vscode';
55
import { launch } from './net/browser';
66
import { IPersistentStateFactory } from './persistentState';
77

@@ -10,7 +10,12 @@ type deprecatedFeatureInfo = {
1010
message: string;
1111
moreInfoUrl: string;
1212
commands?: string[];
13-
setting?: string;
13+
setting?: deprecatedSettingAndValue;
14+
};
15+
16+
type deprecatedSettingAndValue = {
17+
setting: string;
18+
values?: {}[];
1419
};
1520

1621
const jupyterDeprecationInfo: deprecatedFeatureInfo = {
@@ -27,7 +32,13 @@ const deprecatedFeatures: deprecatedFeatureInfo[] = [
2732
doNotDisplayPromptStateKey: 'SHOW_DEPRECATED_FEATURE_PROMPT_FORMAT_ON_SAVE',
2833
message: 'The setting \'python.formatting.formatOnSave\' is deprecated, please use \'editor.formatOnSave\'.',
2934
moreInfoUrl: 'https://github.com/Microsoft/vscode-python/issues/309',
30-
setting: 'formatting.formatOnSave'
35+
setting: { setting: 'formatting.formatOnSave', values: ['true', true] }
36+
},
37+
{
38+
doNotDisplayPromptStateKey: 'SHOW_DEPRECATED_FEATURE_PROMPT_LINT_ON_TEXT_CHANGE',
39+
message: 'The setting \'python.linting.lintOnTextChange\' is deprecated, please enable \'python.linting.lintOnSave\' and \'files.autoSave\'.',
40+
moreInfoUrl: 'https://github.com/Microsoft/vscode-python/issues/313',
41+
setting: { setting: 'linting.lintOnTextChange', values: ['true', true] }
3142
}
3243
];
3344

@@ -37,7 +48,6 @@ export interface IFeatureDeprecationManager extends Disposable {
3748

3849
export class FeatureDeprecationManager implements IFeatureDeprecationManager {
3950
private disposables: Disposable[] = [];
40-
private settingDeprecationNotified: string[] = [];
4151
constructor(private persistentStateFactory: IPersistentStateFactory, private jupyterExtensionInstalled: boolean) { }
4252
public dispose() {
4353
this.disposables.forEach(disposable => disposable.dispose());
@@ -59,26 +69,31 @@ export class FeatureDeprecationManager implements IFeatureDeprecationManager {
5969
}
6070
}
6171
private checkAndNotifyDeprecatedSetting(deprecatedInfo: deprecatedFeatureInfo) {
62-
const setting = deprecatedInfo.setting!;
6372
let notify = false;
6473
if (Array.isArray(workspace.workspaceFolders) && workspace.workspaceFolders.length > 0) {
6574
workspace.workspaceFolders.forEach(workspaceFolder => {
6675
if (notify) {
6776
return;
6877
}
69-
const pythonConfig = workspace.getConfiguration('python', workspaceFolder.uri);
70-
notify = pythonConfig.has(setting) && this.settingDeprecationNotified.indexOf(setting) === -1;
78+
notify = this.isDeprecatedSettingAndValueUsed(workspace.getConfiguration('python', workspaceFolder.uri), deprecatedInfo.setting!);
7179
});
7280
} else {
73-
const pythonConfig = workspace.getConfiguration('python');
74-
notify = pythonConfig.has(setting) && this.settingDeprecationNotified.indexOf(setting) === -1;
81+
notify = this.isDeprecatedSettingAndValueUsed(workspace.getConfiguration('python'), deprecatedInfo.setting!);
7582
}
7683

7784
if (notify) {
78-
this.settingDeprecationNotified.push(setting);
7985
this.notifyDeprecation(deprecatedInfo);
8086
}
8187
}
88+
private isDeprecatedSettingAndValueUsed(pythonConfig: WorkspaceConfiguration, deprecatedSetting: deprecatedSettingAndValue) {
89+
if (!pythonConfig.has(deprecatedSetting.setting)) {
90+
return false;
91+
}
92+
if (!Array.isArray(deprecatedSetting.values) || deprecatedSetting.values.length === 0) {
93+
return true;
94+
}
95+
return deprecatedSetting.values.indexOf(pythonConfig.get(deprecatedSetting.setting)!) >= 0;
96+
}
8297
private async notifyDeprecation(deprecatedInfo: deprecatedFeatureInfo) {
8398
const notificationPromptEnabled = this.persistentStateFactory.createGlobalPersistentState(deprecatedInfo.doNotDisplayPromptStateKey, true);
8499
if (!notificationPromptEnabled.value) {

src/test/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const fileInNonRootWorkspace = path.join(__dirname, '..', '..', 'src', 'test', '
88
export const rootWorkspaceUri = getWorkspaceRoot();
99

1010
export type PythonSettingKeys = 'workspaceSymbols.enabled' | 'pythonPath' |
11-
'linting.lintOnSave' | 'linting.lintOnTextChange' |
11+
'linting.lintOnSave' |
1212
'linting.enabled' | 'linting.pylintEnabled' |
1313
'linting.flake8Enabled' | 'linting.pep8Enabled' | 'linting.pylamaEnabled' |
1414
'linting.prospectorEnabled' | 'linting.pydocstyleEnabled' | 'linting.mypyEnabled' |

src/test/linters/lint.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as assert from 'assert';
2-
import * as fs from 'fs-extra';
32
import * as path from 'path';
43
import * as vscode from 'vscode';
54
import { PythonSettings } from '../../client/common/configSettings';
@@ -22,7 +21,6 @@ const pep8ConfigPath = path.join(pythoFilesPath, 'pep8config');
2221
const pydocstyleConfigPath27 = path.join(pythoFilesPath, 'pydocstyleconfig27');
2322
const pylintConfigPath = path.join(pythoFilesPath, 'pylintconfig');
2423
const fileToLint = path.join(pythoFilesPath, 'file.py');
25-
let pylintFileToLintLines: string[] = [];
2624

2725
const pylintMessagesToBeReturned: baseLinter.ILintMessage[] = [
2826
{ line: 24, column: 0, severity: baseLinter.LintMessageSeverity.Information, code: 'I0011', message: 'Locally disabling no-member (E1101)', provider: '', type: '' },
@@ -114,7 +112,6 @@ suite('Linting', () => {
114112
const isPython3Deferred = createDeferred<boolean>();
115113
const isPython3 = isPython3Deferred.promise;
116114
suiteSetup(async () => {
117-
pylintFileToLintLines = fs.readFileSync(fileToLint).toString('utf-8').split(/\r?\n/g);
118115
await initialize();
119116
const version = await execPythonFile(fileToLint, PythonSettings.getInstance(vscode.Uri.file(fileToLint)).pythonPath, ['--version'], __dirname, true);
120117
isPython3Deferred.resolve(version.indexOf('3.') >= 0);
@@ -135,7 +132,6 @@ suite('Linting', () => {
135132
await updateSetting('linting.enabled', true, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
136133
}
137134
await updateSetting('linting.lintOnSave', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
138-
await updateSetting('linting.lintOnTextChange', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
139135
await updateSetting('linting.pylintEnabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
140136
await updateSetting('linting.flake8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
141137
await updateSetting('linting.pep8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
@@ -146,7 +142,6 @@ suite('Linting', () => {
146142

147143
if (IS_MULTI_ROOT_TEST) {
148144
await updateSetting('linting.lintOnSave', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
149-
await updateSetting('linting.lintOnTextChange', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
150145
await updateSetting('linting.pylintEnabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
151146
await updateSetting('linting.flake8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
152147
await updateSetting('linting.pep8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
@@ -164,8 +159,7 @@ suite('Linting', () => {
164159
const messages = await linter.lint(editor.document, cancelToken.token);
165160
if (enabled) {
166161
assert.notEqual(messages.length, 0, `No linter errors when linter is enabled, Output - ${output.output}`);
167-
}
168-
else {
162+
} else {
169163
assert.equal(messages.length, 0, `Errors returned when linter is disabled, Output - ${output.output}`);
170164
}
171165
}
@@ -217,8 +211,7 @@ suite('Linting', () => {
217211
const messages = await linter.lint(editor.document, cancelToken.token);
218212
if (messagesToBeReceived.length === 0) {
219213
assert.equal(messages.length, 0, `No errors in linter, Output - ${outputChannel.output}`);
220-
}
221-
else {
214+
} else {
222215
if (outputChannel.output.indexOf('ENOENT') === -1) {
223216
// Pylint for Python Version 2.7 could return 80 linter messages, where as in 3.5 it might only return 1.
224217
// Looks like pylint stops linting as soon as it comes across any ERRORS.

0 commit comments

Comments
 (0)