[PyQt] Wrong type annotation for qInstallMessageHandler

Florian Bruhin me at the-compiler.org
Mon Nov 26 22:20:49 GMT 2018


On Mon, Nov 26, 2018 at 09:01:16PM +0100, Florian Bruhin wrote:
> 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.

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 | me at 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/
-------------- 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/20181126/7fecf8da/attachment.sig>


More information about the PyQt mailing list