-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
Make PySide2 stubs work when loaded through Qt.py #1318
Comments
I tried this on my Windows 7 workstation and it doesn’t seem to work. The .pyi files are nowhere to be found. This is immediately after installing PySide2 v5.12.13 and Qt.py. Is it possible this is OS-dependent? (looks like you’re on a Mac?) |
On my mac, I just $ cd venv/lib/python3.7/site-packages/pyside2
$ ls *.pyi
Qt3DAnimation.pyi QtCore.pyi QtNetwork.pyi QtScxml.pyi QtWebEngine.pyi
Qt3DCore.pyi QtDataVisualization.pyi QtOpenGL.pyi QtSensors.pyi QtWebEngineCore.pyi
Qt3DExtras.pyi QtGui.pyi QtPositioning.pyi QtSql.pyi QtWebEngineWidgets.pyi
Qt3DInput.pyi QtHelp.pyi QtPrintSupport.pyi QtSvg.pyi QtWebSockets.pyi
Qt3DLogic.pyi QtLocation.pyi QtQml.pyi QtTest.pyi QtWidgets.pyi
Qt3DRender.pyi QtMacExtras.pyi QtQuick.pyi QtTextToSpeech.pyi QtXml.pyi
QtCharts.pyi QtMultimedia.pyi QtQuickWidgets.pyi QtUiTools.pyi QtXmlPatterns.pyi
QtConcurrent.pyi QtMultimediaWidgets.pyi QtRemoteObjects.pyi QtWebChannel.pyi
$ python --version
Python 3.7.3 You don't see them inside the package? |
Unfortunately no. I also installed via pip (
The directory seems to contain everything but .pyi files. I get nothing from a |
I installed PySide2 / Qt.py for Python 2 and the .pyi files are there for me
This is the command that was used to install:
I use Centos 7, by the way |
@dwtd You might need to try @ColinKennedy @fredrikaverpil So I suppose with the current master branch completion for PySide2 is not working but not for Qt.py?! |
I'll have to look into this more over the weekend as I'm short for time but I wasn't aware that Jedi supported .pyi files. #839 Also there's a thread on PyCharm / Intellisense support which may be relevant to this issue thread. |
Thanks, all. I tried the same install on my Mac, and sure enough, the .pyi files are installed there. Looks like this might be specific to Windows 7. I also tried copying the .pyi files from my Mac to my PC (total hack I know) but no luck there either. @davidhalter Thanks for the suggestion. I confirmed that the python modules in my virtual environment are all current. @ColinKennedy Thanks for the link to the other thread. I had actually started there, wasn't able to get things working, and then found this thread. I'll switch my project back to pure PySide2 for now, but I'm happy to help troubleshooting if you all have additional ideas. |
I can confirm that I also do not see the *.pyi files on Windows. I have posted about this in the PySide2 gitter channel.
@davidhalter I am unsure how I can make use of the master branch to try it out. I am using vscode. Can I somehow replace the bundled jedi with the master branch one? |
@davidhalter I realized jedi is just dumped into a folder within the vscode-python extension. I tried replacing it, but then jedi broke completely, it seems. I have reached out to some of the devs to see if they can give me a pointer on any additional steps I must take... EDIT: I was able to debug via the console in the "Developer Tools" of vscode. Turns out parso had to be updated and |
@davidhalter I got jedi from master branch working in vscode now. I can confirm that autocomplete works with PySide2 but not with Qt.py. |
It's possible that something needs to be done on Microsoft's side with the vscode-python custom completion.py file to make this all work? |
Quick proof of .pyi working in vscode: Although the .pyi bundled with PySide2 cannot be loaded through Qt.py (which is what this issue is about). Steps to enable .pyi files in vscode:
|
For the second step you could also just write:
|
@davidhalter ah, yes - much better. Do you think that the Qt.py "passthrough" is not working because of jedi or because of vscode's jedi implementation? |
The Qt passthrough is not working, because it's dynamic. If you look at the source code, you can see that it's even really hard to understand for a human. There's a couple of possible solutions:
Not sure though how much of the logic inside Qt.py is actually needed. There's absolutely no way Jedi ever understands the crazy logic of Qt.py without hardcoding it. |
Which source code are you referring to? I am one of the developers behind Qt.py and all it really does is replace itself with the Qt binding you have available in your environment (e.g. PySide2). The core purpose of Qt.py is to provide a way to write PySide2 code which is backwards compatible with PySide/PyQt4 (and will also work with PyQt5). And for this purpose, the way the replacement is performed gets complicated. For example, a certain module was moved between Qt4 and Qt5 and thus needs remapping. Qt.py is widely used and adopted in the feature films business, where a bunch of Qt-based 3D/animation software which has Python scripting capabilities are used in a variety of versions within the same company. Nobody wants to maintain separate code for all of these Qt bindings and Qt.py makes it possible to avoid that. So, as you might imagine some of us working with Qt.py sorely miss the intellisense/autocompletion... and here we are 😄 For some reason, this kind of "passthrough" just works in PyCharm and I am trying to figure out how this is possible and if this can somehow be enabled for my favourite editor (vscode) as well, and Jedi looks like my best bet right now. But I take it then that you don't think Jedi can enable this behavior?
Oh, this sounds interesting but I am not sure in which way you mean. How would I go about trying this? I just tweaked the file structure a little bit and now I can actually make use of the vanilla PySide2 .pyi files when using Qt.py. So perhaps this is the best way forward: mottosso/Qt.py#199 (comment) unless you can come to think of a less brute force approach? Either way, I am very grateful for your work and I am super happy to see you devoted your time to add support for typeshed/stubs! As soon as jedi gets a release with typeshed/stubs I'll make a PR to get it into vscode! ❤️ |
It's something that would need either a plugin structure for Jedi (which isn't public, yet) or we have to hard-code it within Jedi, which I really don't like. So IMO tweaking the file structure is probably the best idea for now. Since you create a compatibility layer between different projects, separate stubs are probably the way to go anyway. |
Ok. Thanks for clarifying. I will close this issue. |
With PyCharm, all you have to do is to
pip install pyside2 qt.py
into your venv, and autocompletion/intellisense will work thanks to the official PySide2 stubs:This is what happens with jedi in vscode:
...and just for completion, this happens with the Python language server (jedi disabled) in vscode (not relevant here):
This was all tested using PySide2 5.12.3.
The text was updated successfully, but these errors were encountered: