Skip to content

Commit 307eb69

Browse files
authored
Merge pull request #109 from altendky/StandardButton__or__
Implement QMessageBox.StandardButton[s].__or__
2 parents a3b2eeb + ffbaf5c commit 307eb69

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1717
* [#51](https://github.com/stlehmann/PyQt5-stubs/pull/51) adds `pyqtBoundSignal.signal` hinted as `str`
1818

1919
### Changed
20+
* [#109](https://github.com/stlehmann/PyQt5-stubs/pull/109) `.__or__()` for `QMessageBox.StandardButton` and `QMessageBox.StandardButtons`
2021
* [#126](https://github.com/stlehmann/PyQt5-stubs/pull/126) fix `QCoreApplication.instance()` return type to be optional
2122
* [#102](https://github.com/stlehmann/PyQt5-stubs/pull/102) fix `pyqtSlot` parameter typing and overloads
2223
* [#104](https://github.com/stlehmann/PyQt5-stubs/pull/104) `sip.voidptr` handles integer values and sequences and takes `self`

PyQt5-stubs/QtWidgets.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6478,6 +6478,11 @@ class QMenuBar(QWidget):
64786478
class QMessageBox(QDialog):
64796479

64806480
class StandardButton(int):
6481+
@typing.overload # type: ignore[override]
6482+
def __or__(self, other: typing.Union['QMessageBox.StandardButton', 'QMessageBox.StandardButtons']) -> 'QMessageBox.StandardButtons': ... # type: ignore[misc]
6483+
@typing.overload
6484+
def __or__(self, other: int) -> int: ...
6485+
64816486
NoButton = ... # type: 'QMessageBox.StandardButton'
64826487
Ok = ... # type: 'QMessageBox.StandardButton'
64836488
Save = ... # type: 'QMessageBox.StandardButton'
@@ -6584,6 +6589,7 @@ class QMessageBox(QDialog):
65846589
def __invert__(self) -> 'QMessageBox.StandardButtons': ...
65856590
def __index__(self) -> int: ...
65866591
def __int__(self) -> int: ...
6592+
def __or__(self, other: typing.Union[int, 'QMessageBox.StandardButtons', 'QMessageBox.StandardButton']) -> 'QMessageBox.StandardButtons': ...
65876593

65886594
@typing.overload
65896595
def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ...

tests/qmessagebox.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from PyQt5 import QtWidgets
2+
3+
a = QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Ok # type: QtWidgets.QMessageBox.StandardButtons
4+
b = QtWidgets.QMessageBox.Ok | 0 # type: int
5+
c = a | 0 # type: QtWidgets.QMessageBox.StandardButtons
6+
d = a | QtWidgets.QMessageBox.Ok # type: QtWidgets.QMessageBox.StandardButtons
7+
e = a | a # type: QtWidgets.QMessageBox.StandardButtons

0 commit comments

Comments
 (0)