Skip to content

Commit ccf59c4

Browse files
committed
add support for pylama linter
1 parent c9cc9df commit ccf59c4

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,24 @@
804804
"type": "string"
805805
}
806806
},
807+
"python.linting.pylamaEnabled": {
808+
"type": "boolean",
809+
"default": false,
810+
"description": "Whether to lint Python files using pylama."
811+
},
812+
"python.linting.pylamaPath": {
813+
"type": "string",
814+
"default": "pylama",
815+
"description": "Path to pylama, you can use a custom version of pylama by modifying this setting to include the full path."
816+
},
817+
"python.linting.pylamaArgs": {
818+
"type": "array",
819+
"description": "Arguments passed in. Each argument is a separate item in the array.",
820+
"default": [],
821+
"items": {
822+
"type": "string"
823+
}
824+
},
807825
"python.unitTest.outputWindow": {
808826
"type": "string",
809827
"default": "Python Test Log",

src/client/linters/pylama.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as baseLinter from './baseLinter';
44
import {OutputChannel} from 'vscode';
55
import { Product } from '../common/installer';
66

7+
const REGEX = '(?<file>.py):(?<line>\\d+):(?<column>\\d+): \\[(?<type>\\w+)\\] (?<code>\\w\\d+) (?<message>.*)\\r?(\\n|$)';
8+
79
export class Linter extends baseLinter.BaseLinter {
810
constructor(outputChannel: OutputChannel, workspaceRootPath: string) {
911
super('pylama', Product.pylama, outputChannel, workspaceRootPath);
@@ -20,7 +22,7 @@ export class Linter extends baseLinter.BaseLinter {
2022
let pylamaPath = this.pythonSettings.linting.pylamaPath;
2123
let pylamaArgs = Array.isArray(this.pythonSettings.linting.pylamaArgs) ? this.pythonSettings.linting.pylamaArgs : [];
2224
return new Promise<baseLinter.ILintMessage[]>(resolve => {
23-
this.run(pylamaPath, pylamaArgs.concat(['--format=%(row)d,%(col)d,%(code)s,%(code)s:%(text)s', filePath]), filePath, txtDocumentLines, this.workspaceRootPath).then(messages => {
25+
this.run(pylamaPath, pylamaArgs.concat(['--format=parsable', filePath]), filePath, txtDocumentLines, this.workspaceRootPath, REGEX).then(messages => {
2426
// All messages in pylama are treated as warnings for now
2527
messages.forEach(msg => {
2628
msg.severity = baseLinter.LintMessageSeverity.Information;

0 commit comments

Comments
 (0)