Skip to content

no visual indication of mypy pretty linting errors on path names of >80 chars #16836

Closed

Description

@timforby

Environment data

  • VS Code version: 1.58.2
  • Extension version (available under the Extensions sidebar): v2021.7.1060902895 (Python)
  • OS and version: macOS Mojave - 10.14.6
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.12, 3.7.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: mypy==0.812
  • Relevant/affected Python-related VS Code extensions and their versions: v2021.7.1060902895
  • Value of the python.languageServer setting: Pylance

Expected behaviour

I expect squiggly lines under characters where mypy error occurs.

Actual behaviour

Output logs indicate error but there is no visual indication of a simple mypy error.

Steps to reproduce:

  1. Create file in folder or with name such that the path length is greater than >80 char long.
  2. Ensure --pretty is an argument to mypy and linting for mypy is enabled.
  3. Add following code:
x: int = 's'
  1. Note the lack of visual indication of error from mypy.

Script to reproduce:

mkdir test
cd test
echo "x: int = 's'" >> no_visual_error_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.py
echo "x: int = 's'" >> visual_error.py
echo '{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
		"python.linting.mypyArgs": [
			"--pretty"
		],
		"python.linting.mypyEnabled": true
	}
}' >> test.code-workspace
code test.code-workspace

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

> ~/.pyenv/shims/python -m mypy --pretty ~/test/visual_error.py
cwd: ~/test
> ~/.pyenv/shims/python -m mypy --pretty ~/test/visual_error.py
cwd: ~/test
##########Linting Output - mypy##########
visual_error.py:1: error: Incompatible types in assignment (expression has type
"str", variable has type "int")
    x: int = 's'
             ^
Found 1 error in 1 file (checked 1 source file)
> ~/.pyenv/shims/python -m mypy --pretty ~/test/no_visual_error_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.py
cwd: ~/test
> ~/.pyenv/shims/python -m mypy --pretty ~/test/no_visual_error_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.py
cwd: ~/test
##########Linting Output - mypy##########
no_visual_error_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.py:1: error:
Incompatible types in assignment (expression has type "str", variable has type
"int")
    x: int = 's'
             ^
Found 1 error in 1 file (checked 1 source file)

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Jul 30, 2021
  2. changed the title [-]no visual indication of mypy linting errors on pathnames of >80 chars[/-] [+]no visual indication of mypy pretty linting errors on path names of >80 chars[/+] on Aug 2, 2021
  3. karthiknadig commented on Aug 4, 2021

    @karthiknadig
    Member

    tim (@timforby) Can you run this mypy --pretty . from command line and share the output? I am not able to get errors or warning from mypy from the command line.

  4. timforby commented on Aug 5, 2021

    @timforby
    Author

    Karthik Nadig (@karthiknadig) Here you go:

    $ mypy --pretty .
    visual_error.py:1: error: Incompatible types in assignment (expression has type "str",
    variable has type "int")
        x: int = 's'
                 ^
    no_visual_error_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.py:1: error:
    Incompatible types in assignment (expression has type "str", variable has type "int")
        x: int = 's'
                 ^
    Found 2 errors in 2 files (checked 2 source files)
  5. karthiknadig commented on Aug 5, 2021

    @karthiknadig
    Member

    Looks like with --pretty the error printed out gets split into two lines. The regex we have for mypy output parsing does not handle this scenario.

    return `${escapeRegExp(filepath)}:(?<line>\\d+)(:(?<column>\\d+))?: (?<type>\\w+): (?<message>.*)\\r?(\\n|$)`;

  6. locked as resolved and limited conversation to collaborators on Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions