Fixing imports in type-stubs for Pyright
Phil Thompson
phil at riverbankcomputing.com
Fri May 29 10:22:46 BST 2026
It will be changed in the next release.
Thanks,
Phil
On 28/05/2026 18:08, Mikaël Capelle wrote:
> 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
>>
More information about the PyQt
mailing list