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
1 change: 1 addition & 0 deletions news/2 Fixes/14978.md
Original file line number Diff line number Diff line change
@@ -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))
3 changes: 2 additions & 1 deletion src/client/linters/mypy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { BaseLinter } from './baseLinter';
import { ILintMessage } from './types';

export const REGEX = '(?<file>[^:]+):(?<line>\\d+)(:(?<column>\\d+))?: (?<type>\\w+): (?<message>.*)\\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<ILintMessage[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/test/linters/mypy.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ suite('Linting - MyPy', () => {
{
code: undefined,
message: 'Expression has type "Any"',
column: 21,
column: 20,
line: 12,
type: 'error',
provider: 'mypy',
} as ILintMessage,
],
];
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);
}
Expand Down