[PyQt] Wrong type annotation for qInstallMessageHandler

Phil Thompson phil at riverbankcomputing.com
Tue Nov 27 14:59:21 GMT 2018


On 26 Nov 2018, at 10:20 pm, Florian Bruhin <me at the-compiler.org> wrote:
> 
> 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.

Should be fixed with tonight's sip snapshot.

Thanks,
Phil


More information about the PyQt mailing list