Fixing imports in type-stubs for Pyright
Mikaël Capelle
capelle.mikael at gmail.com
Thu May 28 18:08:50 BST 2026
If you want an example of stubs I think most stubs do import collections
and use collections.abc.
If you want an example of code that throws pyright of:
from PyQt6.QtCore import QDir
QDir().entryInfoList(QDir.Filter.Dirs | QDir.Filter.NoDotAndDotDot)
Because one of the overload of `entryInfoList()` uses collections.abc.
On Thu, May 28, 2026 at 5:48 PM Phil Thompson <phil at riverbankcomputing.com>
wrote:
> On 28/05/2026 10:20, Mikaël Capelle wrote:
> > In many PyQt6 stubs file, abstract collections from `collections.abc`
> > are
> > used, but the import is `collections` which breaks pyright (see
> > https://github.com/microsoft/pyright/issues/5241), which is one of the
> > most
> > commonly used type checker.
> >
> > An easy fix would to import `collections.abc` instead of simply
> > `collections` (or both if both are needed) in the stubs file.
> >
> > Holt59
>
> Can you point me to a specific example?
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20260528/b54bd226/attachment.htm>
More information about the PyQt
mailing list