From f281759d17b62d23f9f4fb7fa4a80f2163b39f82 Mon Sep 17 00:00:00 2001 From: Antti Pessa Date: Thu, 25 Feb 2021 11:14:45 +0200 Subject: [PATCH 1/4] Fix mypy column offset off by one --- src/client/linters/mypy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/linters/mypy.ts b/src/client/linters/mypy.ts index eff5c71be37a..b1da30513b1d 100644 --- a/src/client/linters/mypy.ts +++ b/src/client/linters/mypy.ts @@ -6,10 +6,11 @@ import { BaseLinter } from './baseLinter'; import { ILintMessage } from './types'; export const REGEX = '(?[^:]+):(?\\d+)(:(?\\d+))?: (?\\w+): (?.*)\\r?(\\n|$)'; +const COLUMN_OFF_SET = 1; export class MyPy extends BaseLinter { constructor(outputChannel: OutputChannel, serviceContainer: IServiceContainer) { - super(Product.mypy, outputChannel, serviceContainer); + super(Product.mypy, outputChannel, serviceContainer, COLUMN_OFF_SET); } protected async runLinter(document: TextDocument, cancellation: CancellationToken): Promise { From d8c572384f23e16d51ebb2331ca34a13d05758d8 Mon Sep 17 00:00:00 2001 From: Antti Pessa Date: Thu, 25 Feb 2021 21:46:17 +0200 Subject: [PATCH 2/4] Add news item --- news/2 Fixes/14978.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2 Fixes/14978.md diff --git a/news/2 Fixes/14978.md b/news/2 Fixes/14978.md new file mode 100644 index 000000000000..27990540844c --- /dev/null +++ b/news/2 Fixes/14978.md @@ -0,0 +1 @@ +Fix Mypy linter pointing to wrong column number (off by one). (thanks [anttipessa](https://github.com/anttipessa/), [haalto](https://github.com/haalto/), [JeonCD](https://github.com/JeonCD/) and [junskU](https://github.com/junskU)) From 934038ca39c11c0c22c77346bdc6e1cc22fd5c5b Mon Sep 17 00:00:00 2001 From: Antti Pessa Date: Thu, 25 Feb 2021 22:06:34 +0200 Subject: [PATCH 3/4] Fix unit test --- src/test/linters/mypy.unit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/linters/mypy.unit.test.ts b/src/test/linters/mypy.unit.test.ts index 5da759cb7108..267f85e8386d 100644 --- a/src/test/linters/mypy.unit.test.ts +++ b/src/test/linters/mypy.unit.test.ts @@ -55,7 +55,7 @@ suite('Linting - MyPy', () => { ], ]; for (const [line, expected] of tests) { - const msg = parseLine(line, REGEX, LinterId.MyPy); + const msg = parseLine(line, REGEX, LinterId.MyPy, 1); expect(msg).to.deep.equal(expected); } From feb3b39ecd5b933c3115c522f743ecb83ff4f517 Mon Sep 17 00:00:00 2001 From: Antti Pessa Date: Thu, 25 Feb 2021 22:53:37 +0200 Subject: [PATCH 4/4] Update the expected output --- src/test/linters/mypy.unit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/linters/mypy.unit.test.ts b/src/test/linters/mypy.unit.test.ts index 267f85e8386d..63bd5c8c34b8 100644 --- a/src/test/linters/mypy.unit.test.ts +++ b/src/test/linters/mypy.unit.test.ts @@ -47,7 +47,7 @@ suite('Linting - MyPy', () => { { code: undefined, message: 'Expression has type "Any"', - column: 21, + column: 20, line: 12, type: 'error', provider: 'mypy',