Skip to content

Commit 43bfcb2

Browse files
committed
some typing clarifications
1 parent c019a8d commit 43bfcb2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

trio_websocket/_impl.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import ssl
1010
import struct
1111
import urllib.parse
12-
from typing import List
12+
from typing import List, Optional, Union
1313

1414
import trio
1515
import trio.abc
@@ -711,26 +711,26 @@ def __init__(self, stream, ws_connection, *, host=None, path=None,
711711
``len()``. If a message is received that is larger than this size,
712712
then the connection is closed with code 1009 (Message Too Big).
713713
'''
714-
self._close_reason = None
714+
self._close_reason: Optional[CloseReason] = None
715715
self._id = next(self.__class__.CONNECTION_ID)
716716
self._stream = stream
717717
self._stream_lock = trio.StrictFIFOLock()
718718
self._wsproto = ws_connection
719719
self._message_size = 0
720-
self._message_parts = [] # type: List[bytes|str]
720+
self._message_parts: List[Union[bytes, str]] = []
721721
self._max_message_size = max_message_size
722722
self._reader_running = True
723723
if ws_connection.client:
724-
self._initial_request = Request(host=host, target=path,
724+
self._initial_request: Optional[Request] = Request(host=host, target=path,
725725
subprotocols=client_subprotocols,
726726
extra_headers=client_extra_headers or [])
727727
else:
728728
self._initial_request = None
729729
self._path = path
730-
self._subprotocol = None
731-
self._handshake_headers = None
732-
self._reject_status = None
733-
self._reject_headers = None
730+
self._subprotocol: Optional[str] = None
731+
self._handshake_headers = tuple()
732+
self._reject_status = 0
733+
self._reject_headers = tuple()
734734
self._reject_body = b''
735735
self._send_channel, self._recv_channel = trio.open_memory_channel(
736736
message_queue_size)
@@ -754,7 +754,7 @@ def closed(self):
754754
(Read-only) The reason why the connection was closed, or ``None`` if the
755755
connection is still open.
756756
757-
:rtype: CloseReason
757+
:rtype: Optional[CloseReason]
758758
'''
759759
return self._close_reason
760760

0 commit comments

Comments
 (0)