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

Hints prohibit passing a QEvent.Type to QEvent.registerEventType

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.15.2
    • PySide
    • None

    Description

      https://doc.qt.io/qt-5/qevent.html#Type-enum
      https://doc.qt.io/qt-5/qevent.html#registerEventType

      import PyQt5.QtCore
      reveal_type(PyQt5.QtCore.QEvent.registerEventType)
      reveal_type(PyQt5.QtCore.QEvent.Type.__int__)
      
      import PySide2.QtCore
      reveal_type(PySide2.QtCore.QEvent.registerEventType)
      reveal_type(PySide2.QtCore.QEvent.Type.__int__)
      

      Running mypy on the above code results in this output.

      y.py:2: note: Revealed type is 'def (hint: builtins.int =) -> builtins.int'
      y.py:3: note: Revealed type is 'def (builtins.int) -> builtins.int'
      y.py:6: note: Revealed type is 'def (hint: builtins.int =) -> builtins.int'
      y.py:7: error: "Type[Type]" has no attribute "__int__"
      y.py:7: note: Revealed type is 'Any'
      

      Since QEvent.Type doesn't have, according to the hints, an ._int_() method we can't even explicitly convert. If nothing else, shouldn't we be able to int() an enumerator?

      Attachments

        1. pyside1468_pyqt.py
          0.4 kB
        2. pyside1468.py
          0.5 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            altendky Kyle Altendorf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes