Skip to content

Commit 5046983

Browse files
committed
Rework to automatically convert old settings
1 parent 3c3c79e commit 5046983

File tree

3 files changed

+19
-63
lines changed

3 files changed

+19
-63
lines changed

news/2 Fixes/410.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# Replaced occuances of `pep8` with `pycodestyle.`
2-
## Add new settings:
3-
* python.linting.pycodestyleArgs
4-
* python.linting.pycodestyleCategorySeverity.E
5-
* python.linting.pycodestyleCategorySeverity.W
6-
* python.linting.pycodestyleEnabled
7-
* python.linting.pycodestylePath
8-
## Add depreciation warnings for:
9-
* python.linting.pep8Args
10-
* python.linting.pep8CategorySeverity.E
11-
* python.linting.pep8CategorySeverity.W
12-
* python.linting.pep8Enabled
13-
* python.linting.pep8Path
142

3+
All menntions of pep8 have been replaced with pycodestyle
4+
5+
## Add script to replace outdated settings with the new ones in user settings.json
6+
7+
* python.linting.pep8Args -> python.linting.pycodestyleArgs
8+
* python.linting.pep8CategorySeverity.E -> python.linting.pycodestyleCategorySeverity.E
9+
* python.linting.pep8CategorySeverity.W -> python.linting.pycodestyleCategorySeverity.W
10+
* python.linting.pep8Enabled -> python.linting.pycodestyleEnabled
11+
* python.linting.pep8Path -> python.linting.pycodestylePath

package.json

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,56 +1754,7 @@
17541754
"description": "Path to mypy, you can use a custom version of mypy by modifying this setting to include the full path.",
17551755
"scope": "resource"
17561756
},
1757-
"python.linting.pep8Args": {
1758-
"type": "array",
1759-
"description": "Arguments passed in. Each argument is a separate item in the array.",
1760-
"default": [],
1761-
"items": {
1762-
"type": "string"
1763-
},
1764-
"scope": "resource",
1765-
"deprecationMessage": "pep8 has been renamed to pycodestyle. This settng is replaced by python.formating.pycodestyleArgs"
1766-
},
1767-
"python.linting.pep8CategorySeverity.E": {
1768-
"type": "string",
1769-
"default": "Error",
1770-
"description": "Severity of Pep8 message type 'E'.",
1771-
"enum": [
1772-
"Hint",
1773-
"Error",
1774-
"Information",
1775-
"Warning"
1776-
],
1777-
"scope": "resource",
1778-
"deprecationMessage": "pep8 has been renamed to pycodestyle. This settng is replaced by python.formating.pycodestyleSeverity.E"
1779-
},
1780-
"python.linting.pep8CategorySeverity.W": {
1781-
"type": "string",
1782-
"default": "Warning",
1783-
"description": "Severity of Pep8 message type 'W'.",
1784-
"enum": [
1785-
"Hint",
1786-
"Error",
1787-
"Information",
1788-
"Warning"
1789-
],
1790-
"scope": "resource",
1791-
"deprecationMessage": "pep8 has been renamed to pycodestyle. This settng is replaced by python.formating.pycodestyleSeverity.W"
1792-
},
1793-
"python.linting.pep8Enabled": {
1794-
"type": "boolean",
1795-
"default": false,
1796-
"description": "Whether to lint Python files using pep8",
1797-
"scope": "resource",
1798-
"deprecationMessage": "pep8 has been renamed to pycodestyle. This settng is replaced by python.formating.pycodestyleEnabled"
1799-
},
1800-
"python.linting.pep8Path": {
1801-
"type": "string",
1802-
"default": "pep8",
1803-
"description": "Path to pep8, you can use a custom version of pep8 by modifying this setting to include the full path.",
1804-
"scope": "resource",
1805-
"deprecationMessage": "pep8 has been renamed to pycodestyle. This settng is replaced by python.formating.pycodestylePath"
1806-
},
1757+
18071758
"python.linting.pycodestyleArgs": {
18081759
"type": "array",
18091760
"description": "Arguments passed in. Each argument is a separate item in the array.",

src/client/testing/common/updateTestSettings.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,25 @@ export class UpdateTestSettingService implements IExtensionActivationService {
5353
const setting_pytest_enabled = new RegExp('.pyTestEnabled"', 'g');
5454
const setting_pytest_args = new RegExp('.pyTestArgs"', 'g');
5555
const setting_pytest_path = new RegExp('.pyTestPath"', 'g');
56+
const setting_pep8_args = new RegExp('.(?<!auto)pep8Args', 'g');
57+
const setting_pep8_cat_severity = new RegExp('.pep8CategorySeverity\.', 'g');
58+
const setting_pep8_enabled = new RegExp('.pep8Enabled', 'g');
59+
const setting_pep8_path = new RegExp('.(?<!auto)pep8Path', 'g');
5660

5761
fileContents = fileContents.replace(setting, '"python.testing');
5862
fileContents = fileContents.replace(setting_pytest_enabled, '.pytestEnabled"');
5963
fileContents = fileContents.replace(setting_pytest_args, '.pytestArgs"');
6064
fileContents = fileContents.replace(setting_pytest_path, '.pytestPath"');
65+
fileContents = fileContents.replace(setting_pep8_args, '.pycodestyleArgs');
66+
fileContents = fileContents.replace(setting_pep8_cat_severity, '.pycodestyleCategorySeverity.');
67+
fileContents = fileContents.replace(setting_pep8_enabled, '.pycodestyleEnabled');
68+
fileContents = fileContents.replace(setting_pep8_path, '.pycodestylePath');
6169
await this.fs.writeFile(filePath, fileContents);
6270
}
6371
public async doesFileNeedToBeFixed(filePath: string) {
6472
try {
6573
const contents = await this.fs.readFile(filePath);
66-
return contents.indexOf('python.unitTest.') > 0 || contents.indexOf('.pyTest') > 0;
74+
return contents.indexOf('python.unitTest.') > 0 || contents.indexOf('.pyTest') > 0 || contents.indexOf('.pep8') > 0;
6775
} catch (ex) {
6876
traceError('Failed to check if file needs to be fixed', ex);
6977
return false;

0 commit comments

Comments
 (0)