PyQt6 Signals are not correctly typed

Philippe Fremy phil at
Sat Nov 26 09:58:16 GMT 2022

Hi Jakub,

The PyQt5/6 default stubs are not suitable for type verification with 
mypy. This is known and this is why we have created external stubs .

Currently, there are official stubs released for PyQt5 and PySide2. 
Stubs for PySide6 and PyQt6 are coming but quite slowly.

As Kyle mentionned, you can already benefit from PyQt6 stubs by using 
the git version. I recreated your example and it type-checks correctly 
with PyQt6-stubs on git :

So, I suggest you do just that.

And don't hesitate to open issues on the GitHub PyQt6-stubs if you see 
something not correctly typed.



Le 16/11/2022 à 15:33, Kyle Altendorf a écrit :
> mm, shortcuts that send the email early...
> The PyQt6-stubs haven't made it to PyPI yet so you'll have to install 
> via `pyqt6-stubs @ git+` 
> or similar.
> On Wed, Nov 16, 2022, at 09:31, Kyle Altendorf wrote:
>> The PyQt (and PySide for that matter) official hints need a good bit 
>> of help.  The pyqt5-stubs and pyqt6-stubs are attempts to 1) offer 
>> better hints to users and 2) offer a reference for Phil to work from 
>> to fix the official hints.  I spent a couple years working on PyQt5 
>> stuff but presently have moved on.  There's some other interest in 
>> maintenance, but not a lot of active work (maybe my fault).
>> For signals, well, we don't have a complete solution but we at least 
>> have something a lot better.
>> On Wed, Nov 16, 2022, at 09:24, JakobDev wrote:
>>> 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:
>>> 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.
>>> *Attachments:*
>>>   *
>>>   * PyCharm.png
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: e5KTkvcYd1QhSidI.png
Type: image/png
Size: 56812 bytes
Desc: not available
URL: <>

More information about the PyQt mailing list