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

typing: QtWidget.setParent can be optionally None

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.6.0
    • 6.4.2
    • Type hints
    • None
    • Windows
    • 6280d5060 (dev), 09b06281a (6.5)

    Description

      When setting a widget's parent to None, PyCharm's type checker complains that the type is invalid. This is however valid code but the stub files distributed with PySide6 are incorrect.

      tab_widget.setParent(None)

      The stubs do not allow the parent to be None.

      @overload
      def setParent(self, parent: PySide6.QtWidgets.QWidget) -> None: ...
      @overload
      def setParent(self, parent: PySide6.QtWidgets.QWidget, f: PySide6.QtCore.Qt.WindowType) -> None: ...

       The solution is to either make the type optional or add another overload.

      I believe these stubs are generated somehow so I don't know how you would handle this.

      PYSIDE-1675 is the ticket tracking issues like this I believe.

      Attachments

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              gentlegiantjgc J C
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes