spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.3k stars 1.61k forks source link

pyls-mypy signaling error when including a file in the same directory #13933

Closed Tambup closed 4 years ago

Tambup commented 4 years ago

Problem Description

Using pyls-mypy when i include a simple module created by me it gives me an error in the line where i include this and then doesn't notify any mypy warning.

What steps reproduce the problem?

  1. create a simple file toInclude.py containing a simple function: def func(variable: int): return 19 If func is called inside the file toInclude, it signal the incompatibility type.
  2. create than a second file: import toInclude as inc inc.funz(2.5) the first line signals this error:

cannot find implementation or library stub for module named 'toInclude' (mypy E)

and than suggest a link to the documentation of mypy. The second line has no error.

What is the expected output? What do you see instead?

The error should be on the second line, signaling the type mismatch.

Versions

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.6.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.2 (OK)
pygments >=2.0                 :  2.5.2 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.35.0 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.7.2 (OK)
qtconsole >=4.6.0              :  4.7.7 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  19.0.0 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  None (OK)
numpy >=1.7                    :  1.18.1 (OK)
pandas >=0.13.1                :  None (OK)
scipy >=0.17.0                 :  None (OK)
sympy >=0.7.3                  :  None (OK)

Found solution

To solve this error i changed ~/.local/lib/python3.8/site-packages/pyls_mypy/plugin.py at the following line from (i installed pyls-mypy with pip option --user): live_mode = config.plugin_settings('pyls_mypy').get('live_mode', False) to: live_mode = config.plugin_settings('pyls_mypy').get('live_mode', True)

Could be very worth if in the preferences of spyder (or in some conf file of spyder, not of pyls-mypy) this option could be setted. With this solution to get the errors is mandatory to save before the file.

Thanks for the great work and support.

steff456 commented 4 years ago

Hi @Tambup,

Right now we are working on the integration of pyls_mypy to spyder, https://github.com/spyder-ide/spyder/pull/13360 where we'll add that option in the preferences.

This work is taking some time, so we are planning to add it to our next release after Spyder 4.2.

Thanks for reporting!

steff456 commented 4 years ago

As you found a way to fix it, I'm going to close this issue. For now please continue with that fix until we create the release with mypy :)