1
+ from typing import Optional
2
+
1
3
from talon import actions , app
2
4
3
- from ..targets .target_types import PrimitiveDestination
5
+ from ..targets .target_types import CursorlessTarget , PrimitiveDestination
4
6
from .get_text import cursorless_get_text_action
5
7
from .replace import cursorless_replace_action
6
8
7
9
8
- def cursorless_homophones_action (target : dict ):
10
+ def cursorless_homophones_action (target : CursorlessTarget ):
9
11
"""Replaced target with next homophone"""
10
12
texts = cursorless_get_text_action (target , show_decorations = False )
11
13
try :
@@ -17,16 +19,16 @@ def cursorless_homophones_action(target: dict):
17
19
cursorless_replace_action (destination , updated_texts )
18
20
19
21
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 )
22
24
if not homophones :
23
25
raise LookupError (f"Found no homophones for '{ word } '" )
24
26
index = (homophones .index (word .lower ()) + 1 ) % len (homophones )
25
27
homophone = homophones [index ]
26
28
return format_homophone (word , homophone )
27
29
28
30
29
- def format_homophone (word : str , homophone : str ):
31
+ def format_homophone (word : str , homophone : str ) -> str :
30
32
if word .isupper ():
31
33
return homophone .upper ()
32
34
if word == word .capitalize ():
0 commit comments