-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add stubs for uic #150
Labels
Comments
Looks like we're missing the |
bluebird75
added
enhancement
New feature or request
and removed
bug
Something isn't working
labels
Jan 4, 2022
As a workaround, I added this to my app's code: from typing import TYPE_CHECKING
if TYPE_CHECKING:
# PyQt5-stubs doesn't include the uic module
# https://github.com/python-qt-tools/PyQt5-stubs/issues/150
# I tried adding a stub for it, but then QtCore couldn't be resolved,
# so it seems stubs can't overlap with other stub packages.
# This is a simple workaround, and I could probably move it to a .pyi module,
# and just add a different import here instead of defining a class as a stand-in for a module.
class uic:
@staticmethod
def loadUi(uifile: str, baseinstance: QWidget|None = None, package: str = "", resource_suffix: str = "_rc") -> QWidget:
"""loadUi(uifile, baseinstance=None, package='') -> widget
Load a Qt Designer .ui file and return an instance of the user interface.
uifile is a file name or file-like object containing the .ui file.
baseinstance is an optional instance of the Qt base class. If specified
then the user interface is created in it. Otherwise a new instance of the
base class is automatically created.
package is the optional package which is used as the base for any relative
imports of custom widgets.
resource_suffix is the suffix appended to the basename of any resource file
specified in the .ui file to create the name of the Python module generated
from the resource file by pyrcc4. The default is '_rc', i.e. if the .ui
file specified a resource file called foo.qrc then the corresponding Python
module is foo_rc.
"""
... I'm no longer using PyQt5-stubs as I've upgraded to PyQt6, but this could be used as a headstart if someone wants to add this to the type stubs properly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps
Install PyQt5 package and type the import statement:
from PyQt5 import QtGui, uic
PyCharm will offer to install PyQt5-stubs. Agree.
Actual - uic submodule is marked as unresolved. The code runs.
Reported to JetBrains, and listed as an issue:
https://youtrack.jetbrains.com/issue/PY-47685
The text was updated successfully, but these errors were encountered: