Rogue PyQt6.QtGui.Qt in type annotations
Phil Thompson
phil at riverbankcomputing.com
Wed Nov 24 11:52:30 GMT 2021
On 01/11/2021 16:46, Florian Bruhin wrote:
> 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.
Fixed in the next (SIP) snapshot.
Thanks,
Phil
More information about the PyQt
mailing list