-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
I'm using wsproto in my library httpx-ws. One contributor reported in frankie567/httpx-ws#38, that the data property of BytesMessage is actually a bytearray at runtime, but it's typed as bytes.
Reproducible example
from wsproto import WSConnection, ConnectionType
from wsproto.events import Request, BytesMessage, AcceptConnection
client = WSConnection(ConnectionType.CLIENT)
server = WSConnection(ConnectionType.SERVER)
msg = client.send(Request(host='echo.websocket.org', target='/'))
server.receive_data(msg)
msg = server.send(AcceptConnection())
client.receive_data(msg)
msg = server.send(BytesMessage(b"Hello"))
client.receive_data(msg)
for event in client.events():
if isinstance(event, BytesMessage):
print(type(event.data)) # bytearrayAdditional comment
It's not really a problem since bytes and bytearray are nearly the same, but from type-hints point-of-view, maybe BytesMessage.data should be typed as bytearray.
Metadata
Metadata
Assignees
Labels
No labels