From 0522e83b18149e70d5143e249af4e0561566f929 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Thu, 13 Dec 2018 21:14:03 -0800 Subject: [PATCH 1/3] #3597: Modified mypy linter plugin to support column numbers for reported errors. --- package.json | 3 ++- src/client/linters/mypy.ts | 2 +- src/test/linters/mypy.unit.test.ts | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 051c17cb29c9..2d601ac80393 100644 --- a/package.json +++ b/package.json @@ -1326,7 +1326,8 @@ "description": "Arguments passed in. Each argument is a separate item in the array.", "default": [ "--ignore-missing-imports", - "--follow-imports=silent" + "--follow-imports=silent", + "--show-column-numbers" ], "items": { "type": "string" diff --git a/src/client/linters/mypy.ts b/src/client/linters/mypy.ts index 21b8af3796be..7c8559881a42 100644 --- a/src/client/linters/mypy.ts +++ b/src/client/linters/mypy.ts @@ -5,7 +5,7 @@ import { IServiceContainer } from '../ioc/types'; import { BaseLinter } from './baseLinter'; import { ILintMessage } from './types'; -export const REGEX = '(?.+):(?\\d+): (?\\w+): (?.*)\\r?(\\n|$)'; +export const REGEX = '(?[^:]+):(?\\d+)(:(?\\d+))?: (?\\w+): (?.*)\\r?(\\n|$)'; export class MyPy extends BaseLinter { constructor(outputChannel: OutputChannel, serviceContainer: IServiceContainer) { diff --git a/src/test/linters/mypy.unit.test.ts b/src/test/linters/mypy.unit.test.ts index 44dd2076fd08..1f6e36146c1b 100644 --- a/src/test/linters/mypy.unit.test.ts +++ b/src/test/linters/mypy.unit.test.ts @@ -15,6 +15,7 @@ import { ILintMessage } from '../../client/linters/types'; const output = ` provider.pyi:10: error: Incompatible types in assignment (expression has type "str", variable has type "int") provider.pyi:11: error: Name 'not_declared_var' is not defined +provider.pyi:12:21: error: Expression has type "Any" `; suite('Linting - MyPy', () => { @@ -36,6 +37,14 @@ suite('Linting - MyPy', () => { line: 11, type: 'error', provider: 'mypy' + } as ILintMessage], + [lines[3], { + code: undefined, + message: 'Expression has type "Any"', + column: 21, + line: 12, + type: 'error', + provider: 'mypy' } as ILintMessage] ]; for (const [line, expected] of tests) { From 4a668ac58ec1f8e447d3e2c5f8b550f279a0931c Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 18 Dec 2018 13:28:55 -0800 Subject: [PATCH 2/3] Add news entry --- news/1 Enhancements/3597.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 news/1 Enhancements/3597.md diff --git a/news/1 Enhancements/3597.md b/news/1 Enhancements/3597.md new file mode 100644 index 000000000000..8b1e9b4ddbb2 --- /dev/null +++ b/news/1 Enhancements/3597.md @@ -0,0 +1,2 @@ +Add support for column numbers for problems returned by `mypy`. +(thanks [Eric Traut](https://github.com/erictraut)) From 826d19af648be6d3b5c9eeebc6f3ce0b67e66d1b Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 18 Dec 2018 13:29:13 -0800 Subject: [PATCH 3/3] Add line break --- news/1 Enhancements/3597.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/1 Enhancements/3597.md b/news/1 Enhancements/3597.md index 8b1e9b4ddbb2..728727722619 100644 --- a/news/1 Enhancements/3597.md +++ b/news/1 Enhancements/3597.md @@ -1,2 +1,2 @@ -Add support for column numbers for problems returned by `mypy`. +Add support for column numbers for problems returned by `mypy`. (thanks [Eric Traut](https://github.com/erictraut))