Skip to content

Mypy column numbers are off by one #14978

@gvanrossum

Description

@gvanrossum

Mypy column numbers in error messages are consistently one too high. Pylance column numbers are correct.

I suspect that whoever coded this assumed that mypy error messages use a 0-based column offset, but it doesn't -- like Python SyntaxError messages (and vim and Emacs :-), it uses 1-based column offsets.

Environment data

  • VS Code version: 1.53.0-insider
  • Extension version (available under the Extensions sidebar): v2021.1.416706931
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: None
  • Relevant/affected Python-related VS Code extensions and their versions: Pylance v2020.12.3-pre.1
  • Value of the python.languageServer setting: "Pylance"

Expected behaviour

Error for undefined name 'foo' points at 'f' of 'foo' (the 19th character on the line in the example below)

Actual behaviour

Error points at first 'o' instead (the 20th character)

Steps to reproduce:

Configure both Pylance and mypy. Enter this code in a .py file:

def f(arg: int) -> int:
    return (arg + foo + 1)

Hit F8 once to show the Pylance error pointing at 'f', and again to show the mypy error pointing at 'o'.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions