python-language-server icon indicating copy to clipboard operation
python-language-server copied to clipboard

PyQt5 symbols are not recognized

Open zhangguofu opened this issue 6 years ago • 2 comments

Environment data

  • VS Code version: 1.41.1
  • Extension version (available under the Extensions sidebar): 2019.11.50794
  • OS and version: Windows_NT x64 10.0.18363
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: PyQt5
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info microsoft/vscode-python#3977): "python.jediEnabled": false

Expected behavior

with the settings.json file configured as "python.autoComplete.extraPaths": [ "C:/Users/Administrator/.virtualenvs/PyQt5-w5h0JEeT/Lib/site-packages", "C:/Users/Administrator/.virtualenvs/PyQt5-w5h0JEeT/Lib" ], I expect the code navigation function works, but it does not.

Actual behaviour

for this line: from PyQt5.Qt import * it shows 'from PyQt5.Qt import *' used; unable to detect undefined namesflake8(F403) and if I right click on QApplication symbol and then I select "Go to Definition", it shows "No definition found for QApplication "

meanwhile it works for import sys print(sys.argv) "Go to Definition" for sys.argv get me to correct location in sys.pyi

zhangguofu avatar Dec 24 '19 10:12 zhangguofu

Not entirely sure what unable to detect undefined names flake8(F403) means... flake8 is not part of the LS and F403 is not something LS code outputs.

"No definition found for QApplication " is normal since Qt5 is compiled module in C++ and hence we do not have source to show. Actually, nav to sys.argv also shows 'no definition` since LS normally does not navigate to stubs per https://github.com/microsoft/python-language-server/pull/1831.

MikhailArkhipov avatar Jan 02 '20 23:01 MikhailArkhipov

The original motivation for this issue is that in PyCharm, we can check definitions for PyQt5 modules and it really helps to code quickly and correctly, but for VS Code there is no such experience, and it gets much harder to write PyQt5 programs. After firing this issue, I find out that the PyCharm experience is based on PyQt5-stubs, so I created a new future request for support of PyQt5-stubs for python extension https://github.com/microsoft/python-language-server/issues/1854 So we can close this issue if we are on the same page.

zhangguofu avatar Jan 03 '20 07:01 zhangguofu