55import time
66from collections import deque
77from email .utils import formatdate
8- from typing import Callable , Deque , Dict , List , Optional , Union , cast
8+ from typing import Callable , Deque , Optional , Union , cast
99
1010import aioquic
1111import wsproto
@@ -44,15 +44,15 @@ def __init__(
4444 authority : bytes ,
4545 connection : HttpConnection ,
4646 protocol : QuicConnectionProtocol ,
47- scope : Dict ,
47+ scope : dict ,
4848 stream_ended : bool ,
4949 stream_id : int ,
5050 transmit : Callable [[], None ],
5151 ) -> None :
5252 self .authority = authority
5353 self .connection = connection
5454 self .protocol = protocol
55- self .queue : asyncio .Queue [Dict ] = asyncio .Queue ()
55+ self .queue : asyncio .Queue [dict ] = asyncio .Queue ()
5656 self .scope = scope
5757 self .stream_id = stream_id
5858 self .transmit = transmit
@@ -77,10 +77,10 @@ def http_event_received(self, event: H3Event) -> None:
7777 async def run_asgi (self , app : AsgiApplication ) -> None :
7878 await app (self .scope , self .receive , self .send )
7979
80- async def receive (self ) -> Dict :
80+ async def receive (self ) -> dict :
8181 return await self .queue .get ()
8282
83- async def send (self , message : Dict ) -> None :
83+ async def send (self , message : dict ) -> None :
8484 if message ["type" ] == "http.response.start" :
8585 self .connection .send_headers (
8686 stream_id = self .stream_id ,
@@ -129,14 +129,14 @@ def __init__(
129129 self ,
130130 * ,
131131 connection : HttpConnection ,
132- scope : Dict ,
132+ scope : dict ,
133133 stream_id : int ,
134134 transmit : Callable [[], None ],
135135 ) -> None :
136136 self .closed = False
137137 self .connection = connection
138138 self .http_event_queue : Deque [DataReceived ] = deque ()
139- self .queue : asyncio .Queue [Dict ] = asyncio .Queue ()
139+ self .queue : asyncio .Queue [dict ] = asyncio .Queue ()
140140 self .scope = scope
141141 self .stream_id = stream_id
142142 self .transmit = transmit
@@ -171,10 +171,10 @@ async def run_asgi(self, app: AsgiApplication) -> None:
171171 if not self .closed :
172172 await self .send ({"type" : "websocket.close" , "code" : 1000 })
173173
174- async def receive (self ) -> Dict :
174+ async def receive (self ) -> dict :
175175 return await self .queue .get ()
176176
177- async def send (self , message : Dict ) -> None :
177+ async def send (self , message : dict ) -> None :
178178 data = b""
179179 end_stream = False
180180 if message ["type" ] == "websocket.accept" :
@@ -229,15 +229,15 @@ def __init__(
229229 self ,
230230 * ,
231231 connection : H3Connection ,
232- scope : Dict ,
232+ scope : dict ,
233233 stream_id : int ,
234234 transmit : Callable [[], None ],
235235 ) -> None :
236236 self .accepted = False
237237 self .closed = False
238238 self .connection = connection
239239 self .http_event_queue : Deque [H3Event ] = deque ()
240- self .queue : asyncio .Queue [Dict ] = asyncio .Queue ()
240+ self .queue : asyncio .Queue [dict ] = asyncio .Queue ()
241241 self .scope = scope
242242 self .stream_id = stream_id
243243 self .transmit = transmit
@@ -274,10 +274,10 @@ async def run_asgi(self, app: AsgiApplication) -> None:
274274 if not self .closed :
275275 await self .send ({"type" : "webtransport.close" })
276276
277- async def receive (self ) -> Dict :
277+ async def receive (self ) -> dict :
278278 return await self .queue .get ()
279279
280- async def send (self , message : Dict ) -> None :
280+ async def send (self , message : dict ) -> None :
281281 data = b""
282282 end_stream = False
283283
@@ -325,7 +325,7 @@ async def send(self, message: Dict) -> None:
325325class HttpServerProtocol (QuicConnectionProtocol ):
326326 def __init__ (self , * args , ** kwargs ) -> None :
327327 super ().__init__ (* args , ** kwargs )
328- self ._handlers : Dict [int , Handler ] = {}
328+ self ._handlers : dict [int , Handler ] = {}
329329 self ._http : Optional [HttpConnection ] = None
330330
331331 def http_event_received (self , event : H3Event ) -> None :
@@ -361,9 +361,9 @@ def http_event_received(self, event: H3Event) -> None:
361361 client = (client_addr [0 ], client_addr [1 ])
362362
363363 handler : Handler
364- scope : Dict
364+ scope : dict
365365 if method == "CONNECT" and protocol == "websocket" :
366- subprotocols : List [str ] = []
366+ subprotocols : list [str ] = []
367367 for header , value in event .headers :
368368 if header == b"sec-websocket-protocol" :
369369 subprotocols = [x .strip () for x in value .decode ().split ("," )]
@@ -409,7 +409,7 @@ def http_event_received(self, event: H3Event) -> None:
409409 transmit = self .transmit ,
410410 )
411411 else :
412- extensions : Dict [str , Dict ] = {}
412+ extensions : dict [str , dict ] = {}
413413 if isinstance (self ._http , H3Connection ):
414414 extensions ["http.response.push" ] = {}
415415 scope = {
@@ -471,7 +471,7 @@ class SessionTicketStore:
471471 """
472472
473473 def __init__ (self ) -> None :
474- self .tickets : Dict [bytes , SessionTicket ] = {}
474+ self .tickets : dict [bytes , SessionTicket ] = {}
475475
476476 def add (self , ticket : SessionTicket ) -> None :
477477 self .tickets [ticket .ticket ] = ticket
0 commit comments