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

Type error for multiple inheritance using typing.Generic

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • Some future version
    • 6.5.1
    • PySide
    • None
    • Linux, Python 3.10, PySide6 6.5.1
    • All
    • 30a684904 (dev), 95857c8ca (6.5)

    Description

      As a followup to https://bugreports.qt.io/browse/PYSIDE-2294

      from PySide6.QtWidgets import QApplication, QMainWindow, QLabel
      from typing import Generic, TypeVar
      
      ItemType = TypeVar("ItemType")
      
      
      class MainWindow(QMainWindow, Generic[ItemType]):
          def __init__(self):
              QMainWindow.__init__(self, parent=None)
              self.resize(400, 300)
              self.lbl = QLabel(self)
              self.lbl.setText("XXX")
      
      
      app = QApplication([])
      window = MainWindow()
      window.show()
      app.exec()
      

      creates a similar error

      Traceback (most recent call last):
        File "/home/mark/git/napari/foo.py", line 16, in <module>
          window = MainWindow()
        File "/home/mark/git/napari/foo.py", line 9, in __init__
          QMainWindow.__init__(self, parent=None)
      TypeError: object.__init__() takes exactly one argument (the instance to initialize)
      

      Attachments

        1. pyside2354.py
          0.7 kB
        2. pyside2354_pyqt.py
          0.7 kB

        Issue Links

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

          Activity

            People

              ctismer Christian Tismer
              mark.harfouche Mark Harfouche
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes