PyQt6 Signals are not correctly typed

JakobDev jakobdev at gmx.de
Wed Nov 16 14:24:30 GMT 2022


I demonstrate it with the attached example. It's a very simple Program
that just shows a Button. If you click the Button, it prints Hello
World. So pretty normal. Now let's run mypy on this. It gives you this
error:

testtype.py:13: error: "Callable[[], None]" has no attribute "connect"
Found 1 error in 1 file (checked 1 source file)

Now let's open this in PyCharm. PyCharm also shows a error here. Signals
are not correctly typed. It looks like they are typed as function. To be
clear: This here is just a example. It happens with every Signals, which
is annoying if you work on a bigger Project in PyCharm.

What makes this these even worse, is that PyQt6 comes with a py.typed
(see PEP561). It basically means, that this package can be considered as
statically and correctly typed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testtype.py
Type: text/x-python
Size: 250 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20221116/f68a7fed/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PyCharm.png
Type: image/png
Size: 29106 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20221116/f68a7fed/attachment-0001.png>


More information about the PyQt mailing list