Discussion:
[PyQt] Wrong type annotation for qInstallMessageHandler
Florian Bruhin
2018-11-26 20:01:16 UTC
Permalink
Hi,

The generated QtCore.pyi says:

def qInstallMessageHandler(a0: typing.Optional[typing.Callable[[], None]]) -> typing.Optional[typing.Callable[[], None]]: ...

(i.e., expecting a callable not taking any arguments, which is wrong)
despite the annotation in sip/QtCore/qlogging.sip looking correct:

SIP_PYCALLABLE qInstallMessageHandler(SIP_PYCALLABLE /AllowNone,TypeHint="Optional[Callable[[QtMsgType, QMessageLogContext, QString], None]]"/) /TypeHint="Optional[Callable[[QtMsgType, QMessageLogContext, QString], None]]"/;

Not sure what's wrong there though, and whether it's in PyQt or in sip.

Florian
--
https://www.qutebrowser.org | ***@the-compiler.org (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
Florian Bruhin
2018-11-26 22:20:49 UTC
Permalink
Post by Florian Bruhin
Hi,
def qInstallMessageHandler(a0: typing.Optional[typing.Callable[[], None]]) -> typing.Optional[typing.Callable[[], None]]: ...
(i.e., expecting a callable not taking any arguments, which is wrong)
SIP_PYCALLABLE qInstallMessageHandler(SIP_PYCALLABLE /AllowNone,TypeHint="Optional[Callable[[QtMsgType, QMessageLogContext, QString], None]]"/) /TypeHint="Optional[Callable[[QtMsgType, QMessageLogContext, QString], None]]"/;
Not sure what's wrong there though, and whether it's in PyQt or in sip.
Same issue in with QDesktopServices.setUrlHandler:

sip/QtGui/qdesktopservices.sip says

static void setUrlHandler(const QString &scheme, SIP_PYCALLABLE method /TypeHint="Callable[[QUrl], None]"/);

but QtGui.pyi contains

def setUrlHandler(scheme: str, method: typing.Callable[[], None]) -> None: ...

From a quick grep, QEasingCurve::setCustomType/customType,
QPictureIO::defineIOHandler and QQmlEngine:qmlRegisterSingletonType seem
to be affected as well.

Florian
--
https://www.qutebrowser.org | ***@the-compiler.org (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
Phil Thompson
2018-11-27 14:59:21 UTC
Permalink
Post by Florian Bruhin
Post by Florian Bruhin
Hi,
def qInstallMessageHandler(a0: typing.Optional[typing.Callable[[], None]]) -> typing.Optional[typing.Callable[[], None]]: ...
(i.e., expecting a callable not taking any arguments, which is wrong)
SIP_PYCALLABLE qInstallMessageHandler(SIP_PYCALLABLE /AllowNone,TypeHint="Optional[Callable[[QtMsgType, QMessageLogContext, QString], None]]"/) /TypeHint="Optional[Callable[[QtMsgType, QMessageLogContext, QString], None]]"/;
Not sure what's wrong there though, and whether it's in PyQt or in sip.
sip/QtGui/qdesktopservices.sip says
static void setUrlHandler(const QString &scheme, SIP_PYCALLABLE method /TypeHint="Callable[[QUrl], None]"/);
but QtGui.pyi contains
def setUrlHandler(scheme: str, method: typing.Callable[[], None]) -> None: ...
From a quick grep, QEasingCurve::setCustomType/customType,
QPictureIO::defineIOHandler and QQmlEngine:qmlRegisterSingletonType seem
to be affected as well.
Should be fixed with tonight's sip snapshot.

Thanks,
Phil
_______________________________________________
PyQt mailing list ***@riverbankcomputing.com
https://www.rive

Loading...