Skip to content

Commit 94414bf

Browse files
Fixed regex for Pylama output - comments (#18565)
* Fixed regex for pylama output * added optional error code as it is not reported when using mypy * added regex string parse examples. Small news change
1 parent 601777c commit 94414bf

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

news/2 Fixes/15609.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fixes Pylama and MyPy output parsing (thanks [Nicola Marella](https://github.com/nicolamarella))
1+
Fixes Pylama output parsing with MyPy (thanks [Nicola Marella](https://github.com/nicolamarella))

src/client/linters/pylama.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import { IServiceContainer } from '../ioc/types';
55
import { BaseLinter } from './baseLinter';
66
import { ILintMessage, LintMessageSeverity } from './types';
77

8+
/**
9+
* Example messages to parse from PyLama
10+
* 1. Linter: pycodestyle - recent version removed an extra colon (:) after line:col, hence made it optional in the regex (to be backward compatibile)
11+
* `src/test_py.py:23:60 [E] E226 missing whitespace around arithmetic operator [pycodestyle]`
12+
* 2. Linter: mypy - output is missing the error code, something like `E226` - hence made it optional in the regex
13+
* `src/test_py.py:7:4 [E] Argument 1 to "fn" has incompatible type "str"; expected "int" [mypy]`
14+
*/
15+
816
const REGEX =
917
'(?<file>.py):(?<line>\\d+):(?<column>\\d+):? \\[(?<type>\\w+)\\]( (?<code>\\w\\d+)?:?)? (?<message>.*)\\r?(\\n|$)';
1018
const COLUMN_OFF_SET = 1;

0 commit comments

Comments
 (0)