PyQt6 6.10.2: .pyi stubs use Any and collections.abc without importing them.
Dragan A.
forumwt at gmail.com
Sat Oct 10 01:03:12 BST 2026
Hi,
The type stubs shipped with PyQt6 6.10.2 reference names they don't import.
In strict mode Pyright then reports every signal connect(),
QTimer.singleShot()
and pyqtSlot() use as partially unknown. In our project that is about 1,000
errors.
Environment:
PyQt6 6.10.2, PyQt6-Qt6 6.10.2, PyQt6-sip 13.13.0
Python 3.14.8, Windows 11
Pyright 1.1.414
Problems in PyQt6/QtCore.pyi:
1. Any is used but never imported (line 78):
PYQT_SLOT = typing.Union[collections.abc.Callable[..., Any],
pyqtBoundSignal]
2. collections.abc is used, but only "collections" is imported (line 23):
import collections, re, typing, enum
so collections.abc.Callable does not resolve (lines 68, 69, 78).
The same applies to the other .pyi files that use collections.abc.
3. *types in pyqtSlot() has no annotation (line 69):
def pyqtSlot(*types, name: typing.Optional[str] = ..., result: ...) ->
...
4. __eq__ has no return type (QDate, line 3491, and other classes):
def __eq__(self, other: object): ...
To reproduce, with only PyQt6 6.10.2 and pyright installed:
pip install PyQt6==6.10.2 pyright
pyright pyqt6_stub_repro.py (attached)
Output:
2:62 error: Type of "pyqtSlot" is partially unknown
Type of "pyqtSlot" is "(*types: Unknown, name: str | None = ...,
result: str | None = ...) -> Unknown"
10:6 error: Untyped function decorator obscures type of function
17:1 error: Type of "connect" is partially unknown
Type of "connect" is "(slot: Unknown | pyqtBoundSignal) ->
Connection"
18:1 error: Type of "singleShot" is partially unknown
20:1 error: Type of "same_day" is unknown
21:7 error: Argument type is unknown
6 errors
Adding "from typing import Any" and "import collections.abc" to the .pyi
files removes almost all of them. Annotating *types (e.g. *types: Any) and
adding "-> bool" to __eq__/__ne__ fixes the rest.
Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20261010/3a7e0b76/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqt6_stub_repro.py
Type: application/octet-stream
Size: 452 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20261010/3a7e0b76/attachment.obj>
More information about the PyQt
mailing list