Details
-
Bug
-
Resolution: Fixed
-
P4: Low
-
6.5.2
-
None
-
-
db81f0cb8 (dev), 065d84a16 (6.8), 19d114233 (dev), 3677c9244 (6.8)
Description
QtWidgets.pyi indicates that QApplication.activeModalWidget returns a QWidget:
def activeModalWidget() -> PySide6.QtWidgets.QWidget: ...
However, this code demonstrates that activeModalWidget can also return None:
from PySide6.QtWidgets import QApplication app = QApplication() widget = app.activeModalWidget() print(type(widget)) # prints "<class 'NoneType'>"
So the correct type hint would be
[...] -> PySide6.QtWidgets.QWidget | None: ...
The same is true for many other functions, one example being QTableWidget.item.
Attachments
Issue Links
- is duplicated by
-
PYSIDE-2519 [Type Hints] Return type for QLayout.itemAtPosition must be optional
- Closed
-
PYSIDE-2566 Respect "None" in type stubs
- Closed
- relates to
-
PYSIDE-1467 QCoreApplication.instance() should hint return as optional
- Closed
-
PYSIDE-2638 Segfault when adding None to Layout
- Closed
-
PYSIDE-2941 Type hints: QWidget.window() indicates incorrect optionality
- Closed
For Gerrit Dashboard: PYSIDE-2440 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
603243,3 | type hints: Fix some return annotations which should be optional | dev | pyside/pyside-setup | Status: MERGED | +2 | +1 |
603345,2 | type hints: Fix some return annotations which should be optional | 6.8 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
609303,3 | type hints: Fix some return annotations which should be optional, amended | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
609322,2 | type hints: Fix some return annotations which should be optional, amended | 6.8 | pyside/pyside-setup | Status: MERGED | +2 | 0 |