Closed BryceBeagle closed 2 years ago
I guess that issue exists in various places and whoever is able to solve this receives my eternal gratitude.
progress = QProgressDialog(
"Wait...", "Cancel", 0, 0, self
)
flags = progress.windowFlags()
progress.setWindowFlags(
flags
& ~Qt.WindowCloseButtonHint
& ~Qt.WindowContextHelpButtonHint
| Qt.MSWindowsFixedSizeDialogHint
)
Mypy output:
error: Unsupported operand types for & ("WindowFlags" and "int")
error: Argument 1 to "setWindowFlags" of "QWidget" has incompatible type "int"; expected "Union[WindowFlags, WindowType]"
Current possible solution: cast flags
to int and then cast the complete statement inside setWindowFlags
to Qt.WindowFlags
. It's a bloodbath IMHO...
I am working on a solution for all QFlags based classes
The stubs for QMessageBox.critical(), .information(), etc. show the buttons parameter as non-optional. That causes PyCharm to generate a warning.
You are right. I'll work on a simple fix.
I just checked, pyqt-stubs describes a default valuefor the buttons parameter, making them effectively optional when calling critical() . I checked with PyCharm, it correctly handles this. I tested with the git version of pyqt5-stubs. Which version did you use on your side ?
StandardButtons constructor accepting int has been added as part of #153
Redundant constructor removed as part of #186
All remarks have been implemented.
https://github.com/stlehmann/PyQt5-stubs/blob/a3b2eeba10cbd9db4a2840a3b2a53c15d31039c2/PyQt5-stubs/QtWidgets.pyi#L6575-L6580
There are a couple issues with the
QMessageBox.StandardButtons
constructor annotations.Firstly, the second and third annotations are redundant; other than the args names, which I presume are both auto-generated and inaccurate. Neither are valid kwargs.
Secondly, it can also be constructed using
int
objects. AsQMessageBox.StandardButton
extendsint
, this annotation should just be replaced with usingint
objects.