PyQt6: QEvent.type() returns int instead of QEvent.Type

Florian Bruhin me at the-compiler.org
Mon May 16 16:14:12 BST 2022


On Mon, May 16, 2022 at 09:45:05AM +0100, Phil Thompson wrote:
> On the local PyPI server is an sdist for PyQt6-sip v13.4.0 which implements
> the support for missing enum members. The current PyQt6 snapshot requires
> this version.

Thanks! Something still seems odd about IntEnum support though, e.g.
with Qt.Key:

    >>> from PyQt6.QtGui import QKeySequence
    >>> key = QKeySequence("\x80")[0].key()
    >>> key
    <Key.128: 128>
    >>> type(key)
    <enum 'Key'>
    >>> type(key).__mro__
    (<enum 'Key'>, <enum 'IntEnum'>, <class 'int'>, <enum 'Enum'>, <class 'object'>)
    >>> key > 1
    False

but I'd expect that to be True, just like a normal Qt.Key member:

    >>> from PyQt6.QtCore import Qt
    >>> type(Qt.Key.Key_A)
    <enum 'Key'>
    >>> Qt.Key.Key_A > 1
    True

I'm guessing that the IntEnum implementations should use int.__new__
rather than object.__new__, just like IntFlag._create_pseudo_member_
does:

Flag: https://github.com/python/cpython/blob/v3.10.4/Lib/enum.py#L863
IntFlag: https://github.com/python/cpython/blob/v3.10.4/Lib/enum.py#L972

Florian

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220516/2431a38f/attachment.sig>


More information about the PyQt mailing list