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: Unresolved
    • Not Evaluated
    • None
    • 6.4.2
    • PySide
    • None
    • Windows

    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

          Activity

            People

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

              Dates

                Created:
                Updated: