microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
912 stars 131 forks source link

PyQt5 symbols are not recognized #1853

Open zhangguofu opened 4 years ago

zhangguofu commented 4 years ago

Environment data

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

MikhailArkhipov commented 4 years ago

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.

zhangguofu commented 4 years ago

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.