1- # -*- coding: utf-8 -*- 
21""" 
32hyperframe/frame 
43~~~~~~~~~~~~~~~~ 
98""" 
109import  struct 
1110import  binascii 
11+ from  typing  import  Any , Iterable , Optional , Type 
1212
1313from  .exceptions  import  (
1414    UnknownFrameError , InvalidPaddingError , InvalidFrameError , InvalidDataError 
1515)
1616from  .flags  import  Flag , Flags 
17- from  typing  import  Optional , Tuple , List , Iterable , Any , Dict , Type 
1817
1918
2019# The maximum initial length of a frame. Some frames have shorter maximum 
@@ -44,7 +43,7 @@ class Frame:
4443    The base class for all HTTP/2 frames. 
4544    """ 
4645    #: The flags defined on this type of frame. 
47-     defined_flags : List [Flag ] =  []
46+     defined_flags : list [Flag ] =  []
4847
4948    #: The byte used to define the type of the frame. 
5049    type : Optional [int ] =  None 
@@ -99,7 +98,7 @@ def _body_repr(self) -> str:
9998        return  _raw_data_repr (self .serialize_body ())
10099
101100    @staticmethod  
102-     def  explain (data : memoryview ) ->  Tuple ["Frame" , int ]:
101+     def  explain (data : memoryview ) ->  tuple ["Frame" , int ]:
103102        """ 
104103        Takes a bytestring and tries to parse a single frame and print it. 
105104
@@ -116,7 +115,7 @@ def explain(data: memoryview) -> Tuple["Frame", int]:
116115        return  frame , length 
117116
118117    @staticmethod  
119-     def  parse_frame_header (header : memoryview , strict : bool  =  False ) ->  Tuple ["Frame" , int ]:
118+     def  parse_frame_header (header : memoryview , strict : bool  =  False ) ->  tuple ["Frame" , int ]:
120119        """ 
121120        Takes a 9-byte frame header and returns a tuple of the appropriate 
122121        Frame object and the length that needs to be read from the socket. 
@@ -343,7 +342,7 @@ class PriorityFrame(Priority, Frame):
343342    reprioritisation of existing streams. 
344343    """ 
345344    #: The flags defined for PRIORITY frames. 
346-     defined_flags : List [Flag ] =  []
345+     defined_flags : list [Flag ] =  []
347346
348347    #: The type byte defined for PRIORITY frames. 
349348    type  =  0x02 
@@ -381,7 +380,7 @@ class RstStreamFrame(Frame):
381380    occurred. 
382381    """ 
383382    #: The flags defined for RST_STREAM frames. 
384-     defined_flags : List [Flag ] =  []
383+     defined_flags : list [Flag ] =  []
385384
386385    #: The type byte defined for RST_STREAM frames. 
387386    type  =  0x03 
@@ -454,7 +453,7 @@ class SettingsFrame(Frame):
454453    #: The byte that signals SETTINGS_ENABLE_CONNECT_PROTOCOL setting. 
455454    ENABLE_CONNECT_PROTOCOL  =  0x08 
456455
457-     def  __init__ (self , stream_id : int  =  0 , settings : Optional [Dict [int , int ]] =  None , ** kwargs : Any ) ->  None :
456+     def  __init__ (self , stream_id : int  =  0 , settings : Optional [dict [int , int ]] =  None , ** kwargs : Any ) ->  None :
458457        super ().__init__ (stream_id , ** kwargs )
459458
460459        if  settings  and  "ACK"  in  kwargs .get ("flags" , ()):
@@ -463,7 +462,7 @@ def __init__(self, stream_id: int = 0, settings: Optional[Dict[int, int]] = None
463462            )
464463
465464        #: A dictionary of the setting type byte to the value of the setting. 
466-         self .settings  =  settings  or  {}
465+         self .settings :  dict [ int ,  int ]  =  settings  or  {}
467466
468467    def  _body_repr (self ) ->  str :
469468        return  "settings={}" .format (
@@ -611,7 +610,7 @@ class GoAwayFrame(Frame):
611610    connection. 
612611    """ 
613612    #: The flags defined for GOAWAY frames. 
614-     defined_flags : List [Flag ] =  []
613+     defined_flags : list [Flag ] =  []
615614
616615    #: The type byte defined for GOAWAY frames. 
617616    type  =  0x07 
@@ -679,7 +678,7 @@ class WindowUpdateFrame(Frame):
679678    original sender. 
680679    """ 
681680    #: The flags defined for WINDOW_UPDATE frames. 
682-     defined_flags : List [Flag ] =  []
681+     defined_flags : list [Flag ] =  []
683682
684683    #: The type byte defined for WINDOW_UPDATE frames. 
685684    type  =  0x08 
@@ -951,7 +950,7 @@ def _raw_data_repr(data: Optional[bytes]) -> str:
951950    return  "<hex:"  +  r  +  ">" 
952951
953952
954- _FRAME_CLASSES : List [Type [Frame ]] =  [
953+ _FRAME_CLASSES : list [Type [Frame ]] =  [
955954    DataFrame ,
956955    HeadersFrame ,
957956    PriorityFrame ,
0 commit comments