Skip to content
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

Renamed pep8 to pycodestyle #6570

Merged
merged 14 commits into from
Aug 29, 2019
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
2 changes: 1 addition & 1 deletion .github/test_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ foo = 42 # Marked as a blacklisted name.
- [ ] `Select linter` lists the linter and installs it if necessary
- [ ] mypy works
- [ ] `Select linter` lists the linter and installs it if necessary
- [ ] pep8 works
- [ ] pycodestyle works
- [ ] `Select linter` lists the linter and installs it if necessary
- [ ] prospector works
- [ ] `Select linter` lists the linter and installs it if necessary
Expand Down
2 changes: 1 addition & 1 deletion build/existingFiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"src/client/linters/linterManager.ts",
"src/client/linters/lintingEngine.ts",
"src/client/linters/mypy.ts",
"src/client/linters/pep8.ts",
"src/client/linters/pycodestyle.ts",
"src/client/linters/prospector.ts",
"src/client/linters/pydocstyle.ts",
"src/client/linters/pylama.ts",
Expand Down
2 changes: 1 addition & 1 deletion build/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bandit
black ; python_version>='3.6'
yapf
pylint
pep8
pycodestyle
prospector
pydocstyle
nose
Expand Down
2 changes: 1 addition & 1 deletion data/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"python.pythonPath": "/usr/bin/python3"
}
}
2 changes: 1 addition & 1 deletion data/test.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#%%
print('hello')
print('hello')
12 changes: 12 additions & 0 deletions news/2 Fixes/410.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Replaced occuances of `pep8` with `pycodestyle.`

All menntions of pep8 have been replaced with pycodestyle

## Add script to replace outdated settings with the new ones in user settings.json

* python.linting.pep8Args -> python.linting.pycodestyleArgs
* python.linting.pep8CategorySeverity.E -> python.linting.pycodestyleCategorySeverity.E
* python.linting.pep8CategorySeverity.W -> python.linting.pycodestyleCategorySeverity.W
* python.linting.pep8Enabled -> python.linting.pycodestyleEnabled
* python.linting.pep8Path -> python.linting.pycodestylePath
* (thanks [Marsfan](https://github.com/Marsfan))
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,8 @@
"description": "Path to mypy, you can use a custom version of mypy by modifying this setting to include the full path.",
"scope": "resource"
},
"python.linting.pep8Args": {

"python.linting.pycodestyleArgs": {
"type": "array",
"description": "Arguments passed in. Each argument is a separate item in the array.",
"default": [],
Expand All @@ -1945,10 +1946,10 @@
},
"scope": "resource"
},
"python.linting.pep8CategorySeverity.E": {
"python.linting.pycodestyleCategorySeverity.E": {
"type": "string",
"default": "Error",
"description": "Severity of Pep8 message type 'E'.",
"description": "Severity of pycodestyle message type 'E'.",
"enum": [
"Hint",
"Error",
Expand All @@ -1957,10 +1958,10 @@
],
"scope": "resource"
},
"python.linting.pep8CategorySeverity.W": {
"python.linting.pycodestyleCategorySeverity.W": {
"type": "string",
"default": "Warning",
"description": "Severity of Pep8 message type 'W'.",
"description": "Severity of pycodestyle message type 'W'.",
"enum": [
"Hint",
"Error",
Expand All @@ -1969,16 +1970,16 @@
],
"scope": "resource"
},
"python.linting.pep8Enabled": {
"python.linting.pycodestyleEnabled": {
"type": "boolean",
"default": false,
"description": "Whether to lint Python files using pep8",
"description": "Whether to lint Python files using pycodestyle",
"scope": "resource"
},
"python.linting.pep8Path": {
"python.linting.pycodestylePath": {
"type": "string",
"default": "pep8",
"description": "Path to pep8, you can use a custom version of pep8 by modifying this setting to include the full path.",
"default": "pycodestyle",
"description": "Path to pycodestyle, you can use a custom version of pycodestyle by modifying this setting to include the full path.",
"scope": "resource"
},
"python.linting.prospectorArgs": {
Expand Down
6 changes: 3 additions & 3 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class PythonSettings implements IPythonSettings {
lintOnSave: false, maxNumberOfProblems: 100,
mypyArgs: [], mypyEnabled: false, mypyPath: 'mypy',
banditArgs: [], banditEnabled: false, banditPath: 'bandit',
pep8Args: [], pep8Enabled: false, pep8Path: 'pep8',
pycodestyleArgs: [], pycodestyleEnabled: false, pycodestylePath: 'pycodestyle',
pylamaArgs: [], pylamaEnabled: false, pylamaPath: 'pylama',
prospectorArgs: [], prospectorEnabled: false, prospectorPath: 'prospector',
pydocstyleArgs: [], pydocstyleEnabled: false, pydocstylePath: 'pydocstyle',
Expand All @@ -221,7 +221,7 @@ export class PythonSettings implements IPythonSettings {
refactor: DiagnosticSeverity.Hint,
warning: DiagnosticSeverity.Warning
},
pep8CategorySeverity: {
pycodestyleCategorySeverity: {
E: DiagnosticSeverity.Error,
W: DiagnosticSeverity.Warning
},
Expand All @@ -241,7 +241,7 @@ export class PythonSettings implements IPythonSettings {
};
this.linting.pylintPath = getAbsolutePath(systemVariables.resolveAny(this.linting.pylintPath), workspaceRoot);
this.linting.flake8Path = getAbsolutePath(systemVariables.resolveAny(this.linting.flake8Path), workspaceRoot);
this.linting.pep8Path = getAbsolutePath(systemVariables.resolveAny(this.linting.pep8Path), workspaceRoot);
this.linting.pycodestylePath = getAbsolutePath(systemVariables.resolveAny(this.linting.pycodestylePath), workspaceRoot);
this.linting.pylamaPath = getAbsolutePath(systemVariables.resolveAny(this.linting.pylamaPath), workspaceRoot);
this.linting.prospectorPath = getAbsolutePath(systemVariables.resolveAny(this.linting.prospectorPath), workspaceRoot);
this.linting.pydocstylePath = getAbsolutePath(systemVariables.resolveAny(this.linting.pydocstylePath), workspaceRoot);
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/installer/productInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function translateProductToModule(product: Product, purpose: ModuleNamePurpose):
case Product.pytest: return 'pytest';
case Product.autopep8: return 'autopep8';
case Product.black: return 'black';
case Product.pep8: return 'pep8';
case Product.pycodestyle: return 'pycodestyle';
case Product.pydocstyle: return 'pydocstyle';
case Product.yapf: return 'yapf';
case Product.flake8: return 'flake8';
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/installer/productNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ProductNames.set(Product.black, 'black');
ProductNames.set(Product.flake8, 'flake8');
ProductNames.set(Product.mypy, 'mypy');
ProductNames.set(Product.nosetest, 'nosetest');
ProductNames.set(Product.pep8, 'pep8');
ProductNames.set(Product.pycodestyle, 'pycodestyle');
ProductNames.set(Product.pylama, 'pylama');
ProductNames.set(Product.prospector, 'prospector');
ProductNames.set(Product.pydocstyle, 'pydocstyle');
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/installer/productService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ProductService implements IProductService {
this.ProductTypes.set(Product.bandit, ProductType.Linter);
this.ProductTypes.set(Product.flake8, ProductType.Linter);
this.ProductTypes.set(Product.mypy, ProductType.Linter);
this.ProductTypes.set(Product.pep8, ProductType.Linter);
this.ProductTypes.set(Product.pycodestyle, ProductType.Linter);
this.ProductTypes.set(Product.prospector, ProductType.Linter);
this.ProductTypes.set(Product.pydocstyle, ProductType.Linter);
this.ProductTypes.set(Product.pylama, ProductType.Linter);
Expand Down
12 changes: 6 additions & 6 deletions src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export enum Product {
nosetest = 2,
pylint = 3,
flake8 = 4,
pep8 = 5,
pycodestyle = 5,
pylama = 6,
prospector = 7,
pydocstyle = 8,
Expand Down Expand Up @@ -199,7 +199,7 @@ export interface IPylintCategorySeverity {
readonly error: DiagnosticSeverity;
readonly fatal: DiagnosticSeverity;
}
export interface IPep8CategorySeverity {
export interface IPycodestyleCategorySeverity {
readonly W: DiagnosticSeverity;
readonly E: DiagnosticSeverity;
}
Expand All @@ -220,8 +220,8 @@ export interface ILintingSettings {
readonly prospectorArgs: string[];
readonly pylintEnabled: boolean;
readonly pylintArgs: string[];
readonly pep8Enabled: boolean;
readonly pep8Args: string[];
readonly pycodestyleEnabled: boolean;
readonly pycodestyleArgs: string[];
readonly pylamaEnabled: boolean;
readonly pylamaArgs: string[];
readonly flake8Enabled: boolean;
Expand All @@ -231,12 +231,12 @@ export interface ILintingSettings {
readonly lintOnSave: boolean;
readonly maxNumberOfProblems: number;
readonly pylintCategorySeverity: IPylintCategorySeverity;
readonly pep8CategorySeverity: IPep8CategorySeverity;
readonly pycodestyleCategorySeverity: IPycodestyleCategorySeverity;
readonly flake8CategorySeverity: Flake8CategorySeverity;
readonly mypyCategorySeverity: IMypyCategorySeverity;
prospectorPath: string;
pylintPath: string;
pep8Path: string;
pycodestylePath: string;
pylamaPath: string;
flake8Path: string;
pydocstylePath: string;
Expand Down
2 changes: 1 addition & 1 deletion src/client/linters/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const LINTERID_BY_PRODUCT = new Map<Product, LinterId>([
[Product.flake8, 'flake8'],
[Product.pylint, 'pylint'],
[Product.mypy, 'mypy'],
[Product.pep8, 'pep8'],
[Product.pycodestyle, 'pycodestyle'],
[Product.prospector, 'prospector'],
[Product.pydocstyle, 'pydocstyle'],
[Product.pylama, 'pylama']
Expand Down
8 changes: 4 additions & 4 deletions src/client/linters/linterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { Bandit } from './bandit';
import { Flake8 } from './flake8';
import { LinterInfo, PylintLinterInfo } from './linterInfo';
import { MyPy } from './mypy';
import { Pep8 } from './pep8';
import { Prospector } from './prospector';
import { Pycodestyle } from './pycodestyle';
import { PyDocStyle } from './pydocstyle';
import { PyLama } from './pylama';
import { Pylint } from './pylint';
Expand Down Expand Up @@ -54,7 +54,7 @@ export class LinterManager implements ILinterManager {
new LinterInfo(Product.flake8, 'flake8', this.configService),
new PylintLinterInfo(this.configService, this.workspaceService, ['.pylintrc', 'pylintrc']),
new LinterInfo(Product.mypy, 'mypy', this.configService),
new LinterInfo(Product.pep8, 'pep8', this.configService),
new LinterInfo(Product.pycodestyle, 'pycodestyle', this.configService),
new LinterInfo(Product.prospector, 'prospector', this.configService),
new LinterInfo(Product.pydocstyle, 'pydocstyle', this.configService),
new LinterInfo(Product.pylama, 'pylama', this.configService)
Expand Down Expand Up @@ -134,8 +134,8 @@ export class LinterManager implements ILinterManager {
return new PyLama(outputChannel, serviceContainer);
case Product.pydocstyle:
return new PyDocStyle(outputChannel, serviceContainer);
case Product.pep8:
return new Pep8(outputChannel, serviceContainer);
case Product.pycodestyle:
return new Pycodestyle(outputChannel, serviceContainer);
default:
serviceContainer.get<ILogger>(ILogger).logError(error);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { ILintMessage } from './types';

const COLUMN_OFF_SET = 1;

export class Pep8 extends BaseLinter {
export class Pycodestyle extends BaseLinter {
constructor(outputChannel: OutputChannel, serviceContainer: IServiceContainer) {
super(Product.pep8, outputChannel, serviceContainer, COLUMN_OFF_SET);
super(Product.pycodestyle, outputChannel, serviceContainer, COLUMN_OFF_SET);
}

protected async runLinter(document: TextDocument, cancellation: CancellationToken): Promise<ILintMessage[]> {
const messages = await this.run(['--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s', document.uri.fsPath], document, cancellation);
messages.forEach(msg => {
msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.pep8CategorySeverity);
msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.pycodestyleCategorySeverity);
});
return messages;
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/linters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface IErrorHandler {

// tslint:disable-next-line:no-suspicious-comment
// TODO: Use an enum for LinterID instead of a union of string literals.
export type LinterId = 'flake8' | 'mypy' | 'pep8' | 'prospector' | 'pydocstyle' | 'pylama' | 'pylint' | 'bandit';
export type LinterId = 'flake8' | 'mypy' | 'pycodestyle' | 'prospector' | 'pydocstyle' | 'pylama' | 'pylint' | 'bandit';

export interface ILinterInfo {
readonly id: LinterId;
Expand Down
30 changes: 23 additions & 7 deletions src/client/testing/common/updateTestSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,41 @@ export class UpdateTestSettingService implements IExtensionActivationService {
@swallowExceptions('Failed to update settings.json')
public async fixSettingInFile(filePath: string) {
let fileContents = await this.fs.readFile(filePath);
const setting = new RegExp('"python.unitTest', 'g');
const setting_pytest_enabled = new RegExp('.pyTestEnabled"', 'g');
const setting_pytest_args = new RegExp('.pyTestArgs"', 'g');
const setting_pytest_path = new RegExp('.pyTestPath"', 'g');
const setting_microsoftLanguageServer = new RegExp('.languageServer": "microsoft"', 'g');
const setting_JediLanguageServer = new RegExp('.languageServer": "jedi"', 'g');

const setting = new RegExp('"python\\.unitTest', 'g');
fileContents = fileContents.replace(setting, '"python.testing');

const setting_pytest_enabled = new RegExp('\\.pyTestEnabled"', 'g');
const setting_pytest_args = new RegExp('\\.pyTestArgs"', 'g');
const setting_pytest_path = new RegExp('\\.pyTestPath"', 'g');
fileContents = fileContents.replace(setting_pytest_enabled, '.pytestEnabled"');
fileContents = fileContents.replace(setting_pytest_args, '.pytestArgs"');
fileContents = fileContents.replace(setting_pytest_path, '.pytestPath"');

const setting_microsoftLanguageServer = new RegExp('\\.languageServer": "microsoft"', 'g');
const setting_JediLanguageServer = new RegExp('\\.languageServer": "jedi"', 'g');
fileContents = fileContents.replace(setting_microsoftLanguageServer, '.jediEnabled": false');
fileContents = fileContents.replace(setting_JediLanguageServer, '.jediEnabled": true');

const setting_pep8_args = new RegExp('\\.(?<!auto)pep8Args', 'g');
const setting_pep8_cat_severity = new RegExp('\\.pep8CategorySeverity\\.', 'g');
const setting_pep8_enabled = new RegExp('\\.pep8Enabled', 'g');
const setting_pep8_path = new RegExp('\\.(?<!auto)pep8Path', 'g');
fileContents = fileContents.replace(setting_pep8_args, '.pycodestyleArgs');
fileContents = fileContents.replace(setting_pep8_cat_severity, '.pycodestyleCategorySeverity.');
fileContents = fileContents.replace(setting_pep8_enabled, '.pycodestyleEnabled');
fileContents = fileContents.replace(setting_pep8_path, '.pycodestylePath');

await this.fs.writeFile(filePath, fileContents);
}
public async doesFileNeedToBeFixed(filePath: string) {
try {
const contents = await this.fs.readFile(filePath);
return contents.indexOf('python.unitTest.') > 0 || contents.indexOf('.pyTest') > 0;
return (
contents.indexOf('python.unitTest.') > 0 ||
contents.indexOf('.pyTest') > 0 ||
contents.indexOf('.pep8') > 0
);
} catch (ex) {
traceError('Failed to check if file needs to be fixed', ex);
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/test/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"python.sortImports.args": [],
"python.linting.lintOnSave": false,
"python.linting.enabled": true,
"python.linting.pep8Enabled": false,
"python.linting.pycodestyleEnabled": false,
"python.linting.prospectorEnabled": false,
"python.linting.pydocstyleEnabled": false,
"python.linting.pylamaEnabled": false,
Expand Down
Loading