Missing QByteArray(bytes) overload in PyQt6 docs/types

Phil Thompson phil at riverbankcomputing.com
Wed Jul 5 13:40:03 BST 2023


On 29/06/2023 16:20, Florian Bruhin wrote:
> Hey,
> 
> With PyQt5, help(QByteArray) shows:
> 
>     class QByteArray(sip.simplewrapper)
>      |  QByteArray()
>      |  QByteArray(size: int, c: str)
>      |  QByteArray(a: Union[QByteArray, bytes, bytearray])
> 
> and the type hints also support that.
> 
> However, with PyQt6, it shows:
> 
>     class QByteArray(PyQt6.sip.simplewrapper)
>      |  QByteArray()
>      |  QByteArray(size: int, c: bytes)
>      |  QByteArray(a: QByteArray)
> 
> and the type hints also mark this as wrong:
> 
>     from PyQt6.QtCore import QByteArray
>     print(QByteArray(b"test"))
> 
> See e.g mypy:
> 
>     qba.py:2: error: No overload variant of "QByteArray" matches 
> argument type
> "bytes"  [call-overload]
>     qba.py:2: note: Possible overload variants:
>     qba.py:2: note:     def __init__(self) -> QByteArray
>     qba.py:2: note:     def __init__(self, size: int, c: bytes) -> 
> QByteArray
>     qba.py:2: note:     def __init__(self, a: QByteArray) -> QByteArray
> 
> despite it working fine.
> 
> Florian

Should be fixed in the nest SIP and PyQt6 snapshots.

Thanks,
Phil


More information about the PyQt mailing list