dropbox / mypy-PyCharm-plugin

A simple plugin that allows running mypy from PyCharm and navigate between errors
Apache License 2.0
313 stars 14 forks source link

Does not recognize a stubs package (numpy-stubs) #40

Closed ilirium closed 4 years ago

ilirium commented 4 years ago

The plugin does not recognize a stubs package and it raises the "No library stub file for module" error, however mypy rightly works.

I installed the stubs package from https://github.com/numpy/numpy-stubs: 1) $ git clone https://github.com/numpy/numpy-stubs 2) $ pip install -e numpy-stubs

3) Then I tried to check the next script:

import numpy as np

array = np.array([10, 20, 30])

new_array = np.array()

4) Error:

annotations/num_py/simple.py:1: error: No library stub file for module 'numpy'
annotations/num_py/simple.py:1: note: (Stub files are from https://github.com/python/typeshed)

5) Use mypy to check: $ mypy --follow-imports=error simple.py

6) Output: simple.py:5: error: Too few arguments for "array"

My environment:

ilevkivskyi commented 4 years ago

The plugin uses dmypy run, do you see no errors when you run dmypy run --follow-imports=error simple.py on command line? If no, then maybe you have some tricky virtual environment situation? I remember I had problems with editable installations (the -e flag) so I would not recommend using it unless you really need it. If you do need it, you can try playing with adding something to PATH suffix (right click in plugin window -> Configure plugin...)

ilirium commented 4 years ago

Oh, sorry, it is just the "try to reboot your computer" error :) I've restarted the editor and the error was gone (technically, to solve this error I suppose will be enough to run dmypy restart in a project dir).