Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2941

Type hints: QWidget.window() indicates incorrect optionality

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4: Low P4: Low
    • 6.8.2
    • 6.8.1
    • Type hints
    • None
    • 19d114233 (dev), 3677c9244 (6.8)

      QWidgets.pyi indicates that the return type of window() is optional:

      def window(self) -> PySide6.QtWidgets.QWidget | None: ...
      

      By contrast, I think by construction of QWidget. window() can never return None: either QWidget has no parent, in which case it becomes a window and window() returns itself; or QWidget has a parent, which is another QWidget for which one of the above is true.

      from PySide6.QtWidgets import QWidget, QApplication
      app = QApplication()
      widget = QWidget(None)
      print(widget.window())
      

        For Gerrit Dashboard: PYSIDE-2941
        # Subject Branch Project Status CR V

            ctismer Christian Tismer
            bers bers bers
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes