How does QByteArray convert to bytes ?

Phil Thompson phil at
Fri Apr 2 22:10:08 BST 2021

On 02/04/2021 18:47, Philippe Fremy wrote:
> Hi,
> I am contributing to the PyQt5-stubs project, where we are providing 
> the
> typing information for PyQt5.
> I recently contributed a __bytes__() method to the QByteArray type
> definition, to mark the fact that QByteArray can convert to bytes. But
> ... there is a verification step which fails because QByteArray does 
> not
> contain any __bytes__ method. We have been trying to understand how the
> conversion is performed, without success. Could you give us a hint ?
> And is there a better way to mark the bytes() support than faking this
> __bytes__() method for mypy ?

QByteArray implements the Python buffer protocol (more than just 
bytes()). I don't know if the typing module supports that yet.


More information about the PyQt mailing list