Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix QByteArray to bytes conversion #143

Merged
merged 7 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
* [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/138) update to PyQt5 5.15.3
* [#144](https://github.com/python-qt-tools/PyQt5-stubs/pull/144) add `QTreeWidgetItem.__lt__()` to allow sorting of items in a QTreeWidget
* [#143](https://github.com/python-qt-tools/PyQt5-stubs/pull/143) make `bytes(QByteArray())` valid by incorrectly adding `.__bytes__()` until a proper solution is developed upstream

## 5.15.2.0

Expand Down
9 changes: 9 additions & 0 deletions PyQt5-stubs/QtCore.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3746,6 +3746,15 @@ class QByteArray(sip.simplewrapper):
@typing.overload
def __init__(self, a: typing.Union['QByteArray', bytes, bytearray]) -> None: ...

# TODO: this is a lie... :| it is actually the buffer C-api that is
# implemented. see the discussions below and correct this when a
# proper fix is available.
#
# https://github.com/python-qt-tools/PyQt5-stubs/pull/143
# https://github.com/python/typing/issues/593
# https://bugs.python.org/issue27501
def __bytes__(self) -> bytes: ...

@staticmethod
def fromBase64Encoding(base64: typing.Union['QByteArray', bytes, bytearray], options: typing.Union['QByteArray.Base64Options', 'QByteArray.Base64Option'] = ...) -> 'QByteArray.FromBase64Result': ...
def isLower(self) -> bool: ...
Expand Down
1 change: 1 addition & 0 deletions stubtest.allowlist.to_review
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PyQt5.QtBluetooth.QBluetoothDeviceInfo.Field.__new__
PyQt5.QtCore.QAbstractItemModel.CheckIndexOption.__new__
PyQt5.QtCore.QByteArray.Base64DecodingStatus.__new__
PyQt5.QtCore.QByteArray.__bytes__
PyQt5.QtCore.QCalendar.System.__new__
PyQt5.QtCore.QCborKnownTags.__new__
PyQt5.QtCore.QCborSimpleType.__new__
Expand Down
7 changes: 7 additions & 0 deletions tests/qbytearray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import typing
from PyQt5 import QtCore

some_bytearray = QtCore.QByteArray(3, 'a')
some_bytes = bytes(some_bytearray) # type: bytes