1313_CASE_COST = 1
1414
1515
16- def _substitution_cost (ch_a , ch_b ) :
16+ def _substitution_cost (ch_a : str , ch_b : str ) -> int :
1717 if ch_a == ch_b :
1818 return 0
1919 if ch_a .lower () == ch_b .lower ():
@@ -22,7 +22,7 @@ def _substitution_cost(ch_a, ch_b):
2222
2323
2424@lru_cache (None )
25- def levenshtein (a , b ) :
25+ def levenshtein (a : str , b : str ) -> int :
2626 if not a or not b :
2727 return (len (a ) + len (b )) * _MOVE_COST
2828 option1 = levenshtein (a [:- 1 ], b [:- 1 ]) + _substitution_cost (a [- 1 ], b [- 1 ])
@@ -31,7 +31,7 @@ def levenshtein(a, b):
3131 return min (option1 , option2 , option3 )
3232
3333
34- def main ():
34+ def main () -> None :
3535 parser = argparse .ArgumentParser (description = __doc__ )
3636 parser .add_argument ('output_path' , metavar = 'FILE' , type = str )
3737 parser .add_argument ('--overwrite' , dest = 'overwrite' , action = 'store_const' ,
@@ -48,7 +48,7 @@ def main():
4848 )
4949 return
5050
51- examples = set ()
51+ examples : set [ tuple [ str , str , int ]] = set ()
5252 # Create a lot of non-empty examples, which should end up with a Gauss-like
5353 # distribution for even costs (moves) and odd costs (case substitutions).
5454 while len (examples ) < 9990 :
0 commit comments