Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyPy linting output not being shown in Problems tab #2380

Closed
AllanDaemon opened this issue Aug 13, 2018 · 2 comments · Fixed by #2402
Closed

MyPy linting output not being shown in Problems tab #2380

AllanDaemon opened this issue Aug 13, 2018 · 2 comments · Fixed by #2402
Labels
area-linting bug Issue identified by VS Code Team member as probable bug

Comments

@AllanDaemon
Copy link

AllanDaemon commented Aug 13, 2018

Environment data

  • VS Code version:
    • Version: 1.25.1
    • Commit: 1dfc5e557209371715f655691b1235b6b26a06be
    • Date: 2018-07-11T15:40:20.190Z
    • Electron: 1.7.12
    • Chrome: 58.0.3029.110
    • Node.js: 7.9.0
    • V8: 5.8.283.38
    • Architecture: x64
  • Extension version:
    • Python (ms-python.python) 2018.7.1
    • MagicPython 1.0.12
  • OS and version: Fedora 28 (Linux 4.16.14-300.fc28.x86_64 1228 multi root master #1 SMP)
  • Python version: python3.7 (from fedora package python37)
  • Type of virtual environment used: N/A
  • Relevant/affected Python packages and their versions: mypy 0.620

Actual behavior

mypy and pylint are executed and show errors on the output/python tab, but just the pylint errors are shown on the problems tab.

Expected behavior

problems tab shows both pylint and mypy errors

Steps to reproduce:

  1. Install Python 3.7 (dnf install python37 on Fedora)
  2. Install pip on python3.7
  3. sudo python3.7 -m pip install --pre -U mypy pylint

Logs

Code for test
UPDATE: save file as name.pyi

#!/usr/bin/env python3.7
from __future__ import annotations

a:int = "a"
not_declared_var
##########Linting Output - mypy##########
mypy /home/rea/code/rfs/provider.pyi
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
##########Linting Output - pylint##########
************* Module provider
11,0,error,E0602:Undefined variable 'not_declared_var'

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Show on problem tab:

E0602:Undefined variable 'not_declared_var'

Output from Console under the Developer Tools panel

workbench.main.js:sourcemap:4103 Overwriting grammar scope name to file mapping for scope source.python.
Old grammar file: file:///usr/share/code/resources/app/extensions/python/syntaxes/MagicPython.tmLanguage.json.
New grammar file: file:///home/rea/.vscode/extensions/magicstack.magicpython-1.0.12/grammars/MagicPython.tmLanguage

My config (relevant parts):
User

{
    "python.globalModuleInstallation": true,
    "python.pythonPath": "/usr/bin/python3",
    "files.exclude": {
        "**/__pycache__": true,
        "**/db.sqlite3": true,
    },
    "terminal.integrated.shell.linux": "/bin/shell",
    "files.autoSave": "off",
    "python.linting.pylintPath": "/usr/local/bin/pylint",
    "python.analysis.typeshedPaths": [ "/usr/share/typeshed/"],
    "python.autoComplete.typeshedPaths": [
        "/usr/share/typeshed/"
    ],
}

Workspace

{
	"folders": [
		{
			"path": ".."
		}
	],
	"settings": {  "files.exclude": {
		"**/.git": true,
		"**/.svn": true,
		"**/.hg": true,
		"**/CVS": true,
		"**/.DS_Store": true,
		".gitignore": true,
	},
	"python.pythonPath": "/usr/bin/python3.7",
	"python.linting.pylintPath": "/usr/local/bin/pylint3.7",
	"python.linting.mypyEnabled": true,
	"python.linting.mypyPath": "/usr/bin/mypy3.7",
	"python.linting.mypyArgs": [],
}
}

content of /usr/bin/mypy3.7:

#!/bin/sh
exec python3.7 -m mypy --python-version 3.7 $@

I've looked in #343 and #1440 also, but no luck.

@AllanDaemon AllanDaemon changed the title MyPy linting output not being shoed into Problems tab MyPy linting output not being showed into Problems tab Aug 13, 2018
@d3r3kk d3r3kk changed the title MyPy linting output not being showed into Problems tab MyPy linting output not being shown in Problems tab Aug 13, 2018
@d3r3kk d3r3kk added bug Issue identified by VS Code Team member as probable bug area-linting needs verification labels Aug 13, 2018
@brettcannon
Copy link
Member

I can't replicate:

def spam(x: int) -> str:
    return 3.14

x =

Leads to both mypy and pylint reporting a syntax error:
capture

Removing the syntax error shows mypy results:
capture

It also works with your sample:
capture

My suspicion is that you might have a mis-configuration with mypy or you need to update your version.

@AllanDaemon
Copy link
Author

I found the issue: The MyPy linter module expects the file always to have a .py extension and I am editing an .pyi file.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 13, 2018
DonJayamanne pushed a commit that referenced this issue Sep 25, 2018
Fixes #2380 
The regex expression to match MyPy linter messages expects that the file name has a `.py` extension, that isn't always the case. E.g., `.pyi` files for describing interfaces.

- [X] Title summarizes what is changing
- [X] Includes a [news entry](https://github.com/Microsoft/vscode-python/tree/master/news) file (remember to thank yourself!)
- [X] Unit tests & [code coverage](https://codecov.io/gh/Microsoft/vscode-python) are not adversely affected (within reason)
- [X] Works on all [actively maintained versions of Python](https://devguide.python.org/#status-of-python-branches) (e.g. Python 2.7 & the latest Python 3 release)
- [X] Works on Windows 10, macOS, and Linux (e.g. considered file system case-sensitivity)
- [X] Dependencies are pinned (e.g. `"1.2.3"`, not `"^1.2.3"`)
- [X] `package-lock.json` has been regenerated if dependencies have changed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants