Skip to content
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: 2 additions & 0 deletions news/1 Enhancements/3597.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add support for column numbers for problems returned by `mypy`.
(thanks [Eric Traut](https://github.com/erictraut))
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/client/linters/mypy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IServiceContainer } from '../ioc/types';
import { BaseLinter } from './baseLinter';
import { ILintMessage } from './types';

export const REGEX = '(?<file>.+):(?<line>\\d+): (?<type>\\w+): (?<message>.*)\\r?(\\n|$)';
export const REGEX = '(?<file>[^:]+):(?<line>\\d+)(:(?<column>\\d+))?: (?<type>\\w+): (?<message>.*)\\r?(\\n|$)';

export class MyPy extends BaseLinter {
constructor(outputChannel: OutputChannel, serviceContainer: IServiceContainer) {
Expand Down
9 changes: 9 additions & 0 deletions src/test/linters/mypy.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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) {
Expand Down