1+ from typing import Optional
2+
13from talon import actions , app
24
3- from ..targets .target_types import PrimitiveDestination
5+ from ..targets .target_types import CursorlessTarget , PrimitiveDestination
46from .get_text import cursorless_get_text_action
57from .replace import cursorless_replace_action
68
79
8- def cursorless_homophones_action (target : dict ):
10+ def cursorless_homophones_action (target : CursorlessTarget ):
911 """Replaced target with next homophone"""
1012 texts = cursorless_get_text_action (target , show_decorations = False )
1113 try :
@@ -17,16 +19,16 @@ def cursorless_homophones_action(target: dict):
1719 cursorless_replace_action (destination , updated_texts )
1820
1921
20- def get_next_homophone (word : str ):
21- homophones = actions .user .homophones_get (word )
22+ def get_next_homophone (word : str ) -> str :
23+ homophones : Optional [ list [ str ]] = actions .user .homophones_get (word )
2224 if not homophones :
2325 raise LookupError (f"Found no homophones for '{ word } '" )
2426 index = (homophones .index (word .lower ()) + 1 ) % len (homophones )
2527 homophone = homophones [index ]
2628 return format_homophone (word , homophone )
2729
2830
29- def format_homophone (word : str , homophone : str ):
31+ def format_homophone (word : str , homophone : str ) -> str :
3032 if word .isupper ():
3133 return homophone .upper ()
3234 if word == word .capitalize ():
0 commit comments