@@ -28,13 +28,17 @@ class BaudotCodec(ABC):
2828 """
2929
3030 @abstractmethod
31- def encode (self , value : Value , state : Shift ) -> Tuple [int , Shift ]:
31+ def encode (
32+ self ,
33+ value : Value ,
34+ state : Optional [Shift ]
35+ ) -> Tuple [int , Optional [Shift ]]:
3236 """
3337 Abstract method for encoding a single character or state shift
3438 """
3539
3640 @abstractmethod
37- def decode (self , code : int , state : Shift ) -> Union [ str , Shift ] :
41+ def decode (self , code : int , state : Optional [ Shift ] ) -> Value :
3842 """
3943 Abstract method for decoding a single code.
4044 """
@@ -71,7 +75,11 @@ def __init__(self, name: str, tables: Dict[Shift, Table]):
7175 self .encoding_any : Dict [Value , int ] = enc_any
7276 self .encoding_others : Dict [Value , Set [Tuple [int , Shift ]]] = enc_others
7377
74- def encode (self , value : Value , state : Shift ) -> Tuple [int , Shift ]:
78+ def encode (
79+ self ,
80+ value : Value ,
81+ state : Optional [Shift ]
82+ ) -> Tuple [int , Optional [Shift ]]:
7583 """
7684 Get the code of the given character of Shift for this codec.
7785
@@ -134,7 +142,7 @@ def decode(self, code: int, state: Optional[Shift]) -> Value:
134142 return self .decoding_table [state ][code ]
135143
136144
137- def _verify_tables (tables : Dict [Shift , Table ]):
145+ def _verify_tables (tables : Dict [Shift , Table ]) -> None :
138146 """
139147 Function for verifying that a given input table is correct
140148 """
@@ -155,7 +163,13 @@ def _verify_tables(tables: Dict[Shift, Table]):
155163 raise IncoherentTable ("Shifts in the tables don't match their keys" )
156164
157165
158- def _make_simple_encoding_table (tables : Dict [Shift , Table ]):
166+ def _make_simple_encoding_table (
167+ tables : Dict [Shift , Table ]
168+ ) -> Tuple [
169+ Dict [Value , Tuple [int , Shift ]],
170+ Dict [Value , int ],
171+ Dict [Value , Set [Tuple [int , Shift ]]],
172+ ]:
159173 """
160174 Generates the encoding tables by reversing the decoding table
161175 """
0 commit comments