9
9
import ssl
10
10
import struct
11
11
import urllib .parse
12
- from typing import List
12
+ from typing import List , Optional , Union
13
13
14
14
import trio
15
15
import trio .abc
@@ -711,26 +711,26 @@ def __init__(self, stream, ws_connection, *, host=None, path=None,
711
711
``len()``. If a message is received that is larger than this size,
712
712
then the connection is closed with code 1009 (Message Too Big).
713
713
'''
714
- self ._close_reason = None
714
+ self ._close_reason : Optional [ CloseReason ] = None
715
715
self ._id = next (self .__class__ .CONNECTION_ID )
716
716
self ._stream = stream
717
717
self ._stream_lock = trio .StrictFIFOLock ()
718
718
self ._wsproto = ws_connection
719
719
self ._message_size = 0
720
- self ._message_parts = [] # type : List[bytes| str]
720
+ self ._message_parts : List [Union [ bytes , str ]] = [ ]
721
721
self ._max_message_size = max_message_size
722
722
self ._reader_running = True
723
723
if ws_connection .client :
724
- self ._initial_request = Request (host = host , target = path ,
724
+ self ._initial_request : Optional [ Request ] = Request (host = host , target = path ,
725
725
subprotocols = client_subprotocols ,
726
726
extra_headers = client_extra_headers or [])
727
727
else :
728
728
self ._initial_request = None
729
729
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 ()
734
734
self ._reject_body = b''
735
735
self ._send_channel , self ._recv_channel = trio .open_memory_channel (
736
736
message_queue_size )
@@ -754,7 +754,7 @@ def closed(self):
754
754
(Read-only) The reason why the connection was closed, or ``None`` if the
755
755
connection is still open.
756
756
757
- :rtype: CloseReason
757
+ :rtype: Optional[ CloseReason]
758
758
'''
759
759
return self ._close_reason
760
760
0 commit comments