Details
-
Suggestion
-
Resolution: Fixed
-
Not Evaluated
-
6.8.2
-
None
-
c16d08c5e (dev), 7695f3b2f (6.9), 1c2d0bf41 (6.8)
Description
According to documenation : https://doc.qt.io/qt-6/qtreewidget.html#topLevelItem
QTreeWidget.topLevelItem() may return None if the item is not found.
But current types describes the return value as QTreeWidgetItem instead of Optional[QTreeWidgetItem]
The current typing can lead to incorrect code, where the developers assumes (with the support of type-checking) that an actual widget is always returned, and forgets to check for None. This is precisely the kind of errors for which we want to use typing, to not miss a potential None
(reported on PySide6-stubs)
Attachments
For Gerrit Dashboard: PYSIDE-3058 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
634709,10 | type hints: Fix the return value for QTreeWidget.topLevelItem and QTreeWidget.takeTopLevelItem | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
634912,2 | type hints: Fix the return value for QTreeWidget.topLevelItem and QTreeWidget.takeTopLevelItem | 6.9 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
634963,2 | type hints: Fix the return value for QTreeWidget.topLevelItem and QTreeWidget.takeTopLevelItem | 6.8 | pyside/pyside-setup | Status: MERGED | +2 | 0 |