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 not working for mypy 0.990 - no issues found #20182

Closed
MetRonnie opened this issue Nov 8, 2022 · 12 comments
Closed

Mypy linting not working for mypy 0.990 - no issues found #20182

MetRonnie opened this issue Nov 8, 2022 · 12 comments
Assignees
Labels
area-linting bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@MetRonnie
Copy link

MetRonnie commented Nov 8, 2022

Type: Bug

Behaviour

Expected vs. Actual

Expected: mypy errors are found.

Actual: mypy reports no errors.

Steps to reproduce:

  1. Introduce a deliberate type error
  2. Run mypy <filepath> on the command line to confirm that the problem is genuine
  3. Inspect the Python Output panel to see that you get nothing:
    ##########Linting Output - mypy##########
    
    Success: no issues found in 1 source file
    

Mypy version: mypy 0.990 (compiled: yes)

Edit: I have tested and linting works for mypy 0.981

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

> /opt/conda/bin/conda run -n env_name --no-capture-output python /net/~/.vscode/extensions/ms-python.python-2022.16.1/pythonFiles/get_output_via_markers.py /net/~/.vscode/extensions/ms-python.python-2022.16.1/pythonFiles/linter.py -m mypy --ignore-missing-imports --follow-imports=silent --show-column-numbers --show-error-codes --explicit-package-bases --namespace-packages ./path/to/file.py
cwd: .
##########Linting Output - mypy##########

Success: no issues found in 1 source file

User Settings


condaPath: "<placeholder>"

languageServer: "Pylance"

linting
• mypyArgs: "<placeholder>"
• mypyEnabled: true

formatting
• autopep8Args: "<placeholder>"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Extension version: 2022.16.1
VS Code version: Code 1.72.2 (d045a5eda657f4d7b676dedbfa7aab8207f8a075, 2022-10-12T22:16:26.920Z)
OS version: Linux x64 3.10.0-1160.76.1.el7.x86_64
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz (4 x 2599)
GPU Status 2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off
Load (avg) 1, 3, 3
Memory (System) 7.62GB (1.80GB free)
Process Argv --unity-launch --crash-reporter-id 4cb3165e-6680-471f-992f-0c1e623756f7
Screen Reader no
VM 100%
DESKTOP_SESSION 1-gnome
XDG_CURRENT_DESKTOP GNOME
XDG_SESSION_DESKTOP 1-gnome
XDG_SESSION_TYPE x11
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 8, 2022
@MetRonnie MetRonnie changed the title Mypy not working - no issues found Mypy linting not working for mypy 0.990 - no issues found Nov 8, 2022
@karthiknadig
Copy link
Member

There should be a linter command arguments in the Output > python logs. can you run that in the terminal? it should be running linter.py with few arguments.

@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug area-linting info-needed Issue requires more information from poster labels Nov 8, 2022
@MetRonnie
Copy link
Author

MetRonnie commented Nov 9, 2022

> /opt/conda/bin/conda run -n env_name --no-capture-output python
    /net/~/.vscode/extensions/ms-python.python-2022.16.1/pythonFiles/get_output_via_markers.py
    /net/~/.vscode/extensions/ms-python.python-2022.16.1/pythonFiles/linter.py -m mypy --ignore-missing-imports
    --follow-imports=silent --show-column-numbers --show-error-codes --explicit-package-bases
    --namespace-packages ./path/to/file.py
cwd: .
##########Linting Output - mypy##########

Success: no issues found in 1 source file
  • Not sure why some of the paths show up starting with /net/~/, probably a quirk to do with NFS, but copying and pasting the command and removing the /net/ works for me and shows the mypy errors
  • The mypy options come from my settings (python.linting.mypyArgs). Removing them didn't help.

@najtin
Copy link

najtin commented Nov 9, 2022

Same issue here, without the /net/ thing. The paths look fine.

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.6, apt ubuntu
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): poetry (i guess they use venv?)
  • Value of the python.languageServer setting: Default
  • Mypy: 0.990 (can confirm, works with 0.981)

I use poetry and installed flake8 and mypy in a local venv using poetry. Flake works fine but mypy does not report any issues. To be clear it does report something: Success: no issues found in 1 source file But it should instead report an issue with the code.

Here is the code i want to check:

def a() -> str:
    1

Clearly, mypy should complain about the missing return statement.
Here is the output of the Output tab:

LSP Notebooks experiment is disabled -- not using Pylance
LSP Notebooks interactive window support is disabled -- not in LSP Notebooks experiment
> conda info --json
Python interpreter path: ./.venv/bin/python
> ~/.conda/bin/conda info --json
> . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/printEnvVariables.py
> ~/.julia/conda/3/bin/conda info --json
> ./.venv/bin/python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/get_output_via_markers.py ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/interpreterInfo.py
> /bin/python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/get_output_via_markers.py ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/interpreterInfo.py
> /usr/bin/python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/get_output_via_markers.py ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/interpreterInfo.py
> ~/.julia/conda/3/bin/python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/get_output_via_markers.py ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/interpreterInfo.py
Starting Jedi language server for rootsnakes.
> ./.venv/bin/python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/linter.py -m mypy --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty ./rootsnakes/app.py
cwd: .
> ./.venv/bin/python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/linter.py -m flake8 ./rootsnakes/app.py
cwd: .
##########Linting Output - mypy##########

Success: no issues found in 1 source file

##########Linting Output - flake8##########

When we run the exact same command in the terminal window (with venv activated) or in a fresh shell without activating the venv we get the expected result:

./.venv/bin/python ~/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/linter.py -m mypy --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty ./lol.py
lol.py:1:1: error: Missing return statement  [return]
Found 1 error in 1 file (checked 1 source file)

Extension version: 2022.16.1
VSCodium version: VSCodium 1.72.2 (378660f7dd07287aa34acf90e8fec157425c1ac8, 2022-10-16T23:03:19.989Z)
OS version: Linux x64 5.15.0-52-generic snap
Modes:
Sandboxed: No

System Info
Item Value
CPUs -
GPU Status -
Load (avg) 1, 0, 0
Memory (System) 15.19GB (3.28GB free)
Process Argv --ms-enable-electron-run-as-node --no-sandbox --unity-launch
Screen Reader no
VM 0%
DESKTOP_SESSION mate
XDG_CURRENT_DESKTOP MATE
XDG_SESSION_DESKTOP mate
XDG_SESSION_TYPE x11

@karthiknadig
Copy link
Member

@najtin For flake8 can you try using the flake8 extension from marketplace https://marketplace.visualstudio.com/items?itemName=ms-python.flake8

@najtin
Copy link

najtin commented Nov 9, 2022

I think this is related to the issue above (for completeness python/mypy#14042 )

@najtin
Copy link

najtin commented Nov 9, 2022

@najtin For flake8 can you try using the flake8 extension from marketplace https://marketplace.visualstudio.com/items?itemName=ms-python.flake8

No, flake8 works as expected. This issue does also occur when flake8 is not installed.

@karthiknadig
Copy link
Member

The difference between mypy 0.982 vs 0.990 is that with 0.990 mypy shows error code.

mypy == 0.982

(.venv) C:\GIT\repro\mypytest>python "C:\Users\kanadig\.vscode\extensions\ms-python.python-2022.19.13131832\pythonFiles\linter.py" -m mypy --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty simple.py
simple.py:1:10: error: Incompatible types in assignment (expression has type "str", variable has type "int")
Found 1 error in 1 file (checked 1 source file)

mypy == 0.990

(.venv) C:\GIT\repro\mypytest>python "C:\Users\kanadig\.vscode\extensions\ms-python.python-2022.19.13131832\pythonFiles\linter.py" -m mypy --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty simple.py
simple.py:1:10: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 1 error in 1 file (checked 1 source file)

Even with that difference it seems to be working for me:
image

@karthiknadig
Copy link
Member

Can you share the output from pip list?

@najtin
Copy link

najtin commented Nov 10, 2022

While trying to recreate a minimal working example i found that for some reason it works if you add mypy through poetry add --dev mypy, but it does not work if you change the pyproject.toml by hand and run poetry install. You can also first add mypy through poetry (it works at that moment) and then delete the .venv folder, then run poetry install, resulting in no working linting.
I am really baffled and confused why this would make a difference.

In more detail

To reproduce case (poetry add --dev mypy) run the following:

poetry new example
poetry add --dev mypy
codium .
#mypy works

To reproduce case (poetry install) run the following:

poetry new example
poetry add --dev mypy
rm -r .venv .mypy_cache
poetry install
codium .
#mypy does not work

pyproject.toml:

[tool.poetry]
name = "example-manual"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "example_manual"}]

[tool.poetry.dependencies]
python = "^3.10"


[tool.poetry.group.dev.dependencies]
mypy = "^0.990"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Here is the pip list you requested case (poetry add --dev mypy) (mypy works):

Package           Version
----------------- -------
mypy              0.990
mypy-extensions   0.4.3
pip               22.3
setuptools        65.5.0
tomli             2.0.1
typing_extensions 4.4.0
wheel             0.37.1

case (poetry install) (mypy does not work)

Package           Version Editable project location
----------------- ------- --------------------------------------
example-manual    0.1.0   /home/work/Repositories/example_manual
mypy              0.990
mypy-extensions   0.4.3
pip               22.3
setuptools        65.5.0
tomli             2.0.1
typing_extensions 4.4.0
wheel             0.37.1

These results make me think that this issue should be tracked at mypy under python/mypy#14054 because it seems like the working folder has been added to the path, otherwise pip would not list the project as an installed package. Therefore the plugin here seems to work fine but mypy introduced breaking changes in 0.990, making it an issue with mypy.

@MetRonnie
Copy link
Author

MetRonnie commented Nov 10, 2022

My pip list output:

Click to show
Package                        Version     Editable project location
------------------------------ ----------- --------------------------------------------------
aiofiles                       0.7.0
alabaster                      0.7.12
alembic                        1.8.1
aniso8601                      7.0.0
ansimarkup                     1.5.0
anyio                          3.6.1
argon2-cffi                    21.3.0
argon2-cffi-bindings           21.2.0
astor                          0.8.1
asttokens                      2.0.8
async-generator                1.10
async-timeout                  4.0.2
attrs                          22.1.0
autopep8                       1.7.0
Babel                          2.10.3
backcall                       0.2.0
bandit                         1.7.4
beautifulsoup4                 4.11.1
bleach                         5.0.1
certifi                        2022.9.24
certipy                        0.1.3
cffi                           1.15.1
charset-normalizer             2.1.1
colorama                       0.4.5
contourpy                      1.0.5
coverage                       6.5.0
cryptography                   38.0.1
cycler                         0.11.0
cylc-doc                       0.0.1       <HOME>/github/cylc-doc
cylc-flow                      8.1.0.dev0  <HOME>/github/cylc-flow-8.1
cylc-rose                      1.1.1       <HOME>/github/cylc-rose
cylc-sphinx-extensions         1.4.1       <HOME>/github/cylc-sphinx-extensions
cylc-uiserver                  1.2.0.dev0  <HOME>/github/cylc-uiserver
debugpy                        1.6.3
decorator                      5.1.1
defusedxml                     0.7.1
docutils                       0.17.1
empy                           3.3.4
entrypoints                    0.4
ERAlchemy                      1.2.10
execnet                        1.9.0
executing                      1.1.0
fastjsonschema                 2.16.2
flake8                         5.0.4
flake8-broken-line             0.6.0
flake8-bugbear                 22.9.23
flake8-builtins                1.5.3
flake8-comprehensions          3.10.0
flake8-debugger                4.1.2
flake8-mutable                 1.2.0
flake8-simplify                0.19.3
fonttools                      4.37.4
gitdb                          4.0.9
GitPython                      3.1.27
graphene                       2.1.9
graphene-tornado               2.6.1
graphql-core                   2.3.2
graphql-relay                  2.0.1
graphql-ws                     0.4.4
greenlet                       1.1.3
hieroglyph                     2.1.0
idna                           3.4
imagesize                      1.4.1
iniconfig                      1.1.1
ipython                        8.5.0
jedi                           0.18.1
Jinja2                         3.0.3
jsonschema                     4.16.0
jupyter-client                 7.3.1
jupyter-core                   4.11.1
jupyter-server                 1.19.1
jupyter-telemetry              0.1.0
jupyterhub                     3.0.0
jupyterlab-pygments            0.2.2
kiwisolver                     1.4.4
ldap3                          2.9.1
livereload                     2.6.3
Mako                           1.2.3
MarkupSafe                     2.1.1
matplotlib                     3.6.0
matplotlib-inline              0.1.6
mccabe                         0.7.0
memory-profiler                0.60.0
metomi-isodatetime             1!3.0.0     <HOME>/github/isodatetime
metomi-rose                    2.0.2.dev0  <HOME>/github/rose
mistune                        2.0.4
mypy                           0.990
mypy-extensions                0.4.3
nbclient                       0.6.8
nbconvert                      7.1.0
nbformat                       5.6.1
nest-asyncio                   1.5.6
numpy                          1.23.3
oauthlib                       3.2.1
packaging                      21.3
pamela                         1.0.0
pandas                         1.5.0
pandocfilters                  1.5.0
parso                          0.8.3
pbr                            5.10.0
pexpect                        4.8.0
pickleshare                    0.7.5
Pillow                         9.2.0
pip                            22.2.2
pluggy                         1.0.0
prometheus-client              0.14.1
promise                        2.3
prompt-toolkit                 3.0.31
protobuf                       4.21.7
psutil                         5.9.2
ptyprocess                     0.7.0
pure-eval                      0.2.2
py                             1.11.0
pyasn1                         0.4.8
pycodestyle                    2.9.1
pycparser                      2.21
pyenchant                      3.2.2
pyflakes                       2.5.0
Pygments                       2.13.0
pygraphviz                     1.10
Pympler                        1.0.1
pyOpenSSL                      22.1.0
pyparsing                      3.0.9
pyrsistent                     0.18.1
pytest                         7.1.3
pytest-asyncio                 0.19.0
pytest-cov                     4.0.0
pytest-env                     0.6.2
pytest-forked                  1.4.0
pytest-mock                    3.9.0
pytest-tornasync               0.6.0.post2
pytest-xdist                   2.5.0
python-dateutil                2.8.2
python-json-logger             2.0.4
pytoolconfig                   1.2.2
pytz                           2022.4
PyYAML                         6.0
pyzmq                          22.3.0
requests                       2.28.1
rope                           1.3.0
ruamel.yaml                    0.17.21
ruamel.yaml.clib               0.2.6
Rx                             1.6.1
Send2Trash                     1.8.0
setuptools                     65.4.1
six                            1.16.0
smmap                          5.0.0
snakeviz                       2.1.1
sniffio                        1.3.0
snowballstemmer                2.2.0
soupsieve                      2.3.2.post1
Sphinx                         5.2.3
sphinx-autobuild               2021.3.14
sphinx-rtd-theme               1.0.0
sphinxcontrib-applehelp        1.0.2
sphinxcontrib-devhelp          1.0.2
sphinxcontrib-htmlhelp         2.0.0
sphinxcontrib-httpdomain       1.8.0
sphinxcontrib-jsmath           1.0.1
sphinxcontrib-qthelp           1.0.3
sphinxcontrib-serializinghtml  1.1.5
sphinxcontrib-spelling         7.6.0
sphinxcontrib-svg2pdfconverter 1.2.0
SQLAlchemy                     1.4.41
sqlparse                       0.4.3
stack-data                     0.5.1
stevedore                      4.0.0
terminado                      0.16.0
testfixtures                   7.0.0
tinycss2                       1.1.1
toml                           0.10.2
tomli                          2.0.1
tornado                        6.2
traitlets                      5.4.0
types-aiofiles                 22.1.0
types-Jinja2                   2.11.9
types-MarkupSafe               1.1.10
types-pkg-resources            0.1.3
types-protobuf                 3.20.4
types-setuptools               65.4.0.0
types-six                      1.16.21
typing_extensions              4.3.0
urllib3                        1.26.12
urwid                          2.1.2
wcwidth                        0.2.5
webencodings                   0.5.1
websocket-client               1.4.1
Werkzeug                       0.12.2
wheel                          0.37.1

@karthiknadig
Copy link
Member

Looks like this might be a mypy issue, closing this for now.

Track here: python/mypy#14054

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2022
@MetRonnie
Copy link
Author

Can confirm working again with Mypy 0.991

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2022
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 info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants