How does QByteArray convert to bytes ?

Philippe Fremy phil at
Fri Apr 2 18:47:19 BST 2021


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 ?

Thanks in advance,


ps: thanks for the year-to-year energy that you put into PyQt bindings,
it remains top quality !

More information about the PyQt mailing list