Skip to content

Mypy column numbers are off by one #14978

Closed

Description

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'.

Activity

  1. added
    bug
    triage-needed
    on Dec 15, 2020
  2. ghost removed
    triage-needed
    on Dec 15, 2020
  3. ghost removed on Mar 5, 2021
  4. locked as resolved and limited conversation to collaborators on Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-lintingbuggood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions