Rogue PyQt6.QtGui.Qt in type annotations

Florian Bruhin me at the-compiler.org
Mon Nov 1 16:46:50 GMT 2021


Hi,

In PyQt6 6.2.1, the QtGui.pyi file contains:

    class Qt(PyQt6.sip.simplewrapper):

        def convertFromPlainText(self, plain: str, mode: QtCore.Qt.WhiteSpaceMode = ...) -> str: ...
        def mightBeRichText(self, a0: str) -> bool: ...

It looks like they come from sip/QtGui/qtextdocument.sip:

    namespace Qt
    {
    %TypeHeaderCode
    #include <qtextdocument.h>
    %End

        bool mightBeRichText(const QString &);
        QString convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode = Qt::WhiteSpacePre);
    };

but don't actually exist in Python:

    >>> from PyQt6.QtGui import Qt
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: cannot import name 'Qt' from 'PyQt6.QtGui' (.../site-packages/PyQt6/QtGui.abi3.so)

This causes e.g. VS Code to suggest "from PyQt6.QtGui import Qt" as an
import when it's missing for a "Qt.*" access.

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/20211101/16c12e8f/attachment.sig>


More information about the PyQt mailing list