-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Type stubs? Possible integration with PyQt5-stubs and PySide6-stubs packages? #482
Comments
I have found #479 which seems to relay a similar problem? |
Hi @th3w1zard1 thank you for the feedback! Have you checked the info over the README about setting up MyPy/Pylance args (https://github.com/spyder-ide/qtpy?tab=readme-ov-file#type-checker-integration)? Could it be that is not working for you? Let us know! |
I absolutely don't understand why I missed something so obvious in the README. Perhaps I was relying on PyPI and google too much. Thank you so much for the direct link, this seems to be working fine now after setting up the explanation given for Pylance! Quick question: If I have PyQt5-stubs or PySide6-stubs installed and wanted to use them, would I be able to by configuring this further? Is it worth looking into that at all or are the stubs here usually correct most of the time? I've had issues in the past where sometimes things like QMessageBox wouldn't accept kwargs even though the stubs say they're supported. Example: you can't pass title= and text= in pyqt5 without an exception throwing. |
I also do not seem to be able to get ruff or pylance's auto-imports working for qtpy. This was an issue prior to qtpy with bare pyqt5 but felt I should bring it up in case there was a solution? |
Sorry for the many posts. I've found at least three discrepancies in these stubs than what PyQt5 actually produces. Would you like me to post them here, or each in a new issue thread? example: menu: QMenu = self.build_menu(position)
menu.addAction("Open with Editor").triggered.connect(lambda ins: self.open_selected_resource(ins)) # TODO: disable when file doesn't exist.
executed_action = menu.exec_(self.viewport().mapToGlobal(position))
executed_action_text = executed_action.text menu.exec_ is typed as returning QAction, yet it somehow returned None as I got this error:
|
I'm not totally sure to be honest 😅 , from a quick check seems like those packages extend the stub files that come with each binding to improve usage with Mypy? So maybe in some way when installing those packages, they patch the stubs files for the different bindings? Note that inside QtPy itself we only have a If you end up testing things regarding those sutbs packages and find something that you whitnk could be worthy to mention over the QtPy README Mypy section let us know!
I'm unaware of a solution for that sorry! Maybe related with the response above?
Please post those in a new issue along side some minimum reproducible example/instructions to reproduce. Thank you! |
Bumping because I can't find anything on Google or anywhere else on this repo on this topic.
Does this repo support stubs? If so, what am I supposed to be using for support in things like mypy/pylance?
Currently qtpy seems to be causing tons of type validation failures all over my project. Thousands.
Examples:
Library is available here: https://github.com/NickHugi/PyKotor
Seems to be under the impression that this variable can be from any of the qt versions, despite what's set in API_NAME or QT_API.
There are many community efforts available in getting proper typing and stubs created for these qt python libraries:
https://pypi.org/project/PyQt5-stubs/
https://pypi.org/project/PySide2-stubs/
https://pypi.org/project/types-pyside2/
https://pypi.org/project/PyQt6-stubs/
https://pypi.org/project/PySide6-stubs/
Is there a solution, workaround, or possible in-progress PR I can look at? As I've now fully swapped over to a qtpy abstraction in my python library, this now weeks later reveals that I'm unfortunately unable to ever use MyPy/Pylance again until I find a solution here.
I realize most can be ignored, but examples like this are plain unreadable:
Thanks for your time.
The text was updated successfully, but these errors were encountered: