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

Type hints: QWidget.window() indicates incorrect optionality

    XMLWordPrintable

Details

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

    Description

      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())
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes