Skip to content

Commit fb4864d

Browse files
authored
Fix or suppress all Python type errors (#2307)
- Depends on #2306 - Supercedes #2267 This does add a lot of noise, and it can't be enforced in CI because Talon doesn't publish type stubs (that I know of), so I wonder whether it's worth it 🤔 ## Checklist - [x] I have run Talon spoken form tests - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [x] I have not broken the cheatsheet
1 parent 5326850 commit fb4864d

22 files changed

+101
-51
lines changed

src/actions/actions.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from ..targets.target_types import (
66
CursorlessDestination,
7+
CursorlessExplicitTarget,
78
CursorlessTarget,
89
ImplicitDestination,
910
)
@@ -48,7 +49,7 @@
4849
"custom_action",
4950
]
5051

51-
callback_actions: dict[str, Callable[[CursorlessTarget], None]] = {
52+
callback_actions: dict[str, Callable[[CursorlessExplicitTarget], None]] = {
5253
"nextHomophone": cursorless_homophones_action,
5354
}
5455

@@ -88,7 +89,7 @@ def cursorless_action_or_ide_command(m) -> dict[str, str]:
8889

8990
@mod.action_class
9091
class Actions:
91-
def cursorless_command(action_name: str, target: CursorlessTarget):
92+
def cursorless_command(action_name: str, target: CursorlessExplicitTarget): # pyright: ignore [reportGeneralTypeIssues]
9293
"""Perform cursorless command on target"""
9394
if action_name in callback_actions:
9495
callback_actions[action_name](target)
@@ -107,28 +108,30 @@ def cursorless_command(action_name: str, target: CursorlessTarget):
107108
action = {"name": action_name, "target": target}
108109
actions.user.private_cursorless_command_and_wait(action)
109110

110-
def cursorless_vscode_command(command_id: str, target: CursorlessTarget):
111+
def cursorless_vscode_command(command_id: str, target: CursorlessTarget): # pyright: ignore [reportGeneralTypeIssues]
111112
"""
112113
Perform vscode command on cursorless target
113114
114115
Deprecated: prefer `cursorless_ide_command`
115116
"""
116117
return actions.user.cursorless_ide_command(command_id, target)
117118

118-
def cursorless_ide_command(command_id: str, target: CursorlessTarget):
119+
def cursorless_ide_command(command_id: str, target: CursorlessTarget): # pyright: ignore [reportGeneralTypeIssues]
119120
"""Perform ide command on cursorless target"""
120121
return cursorless_execute_command_action(command_id, target)
121122

122123
def cursorless_insert(
123-
destination: CursorlessDestination, text: Union[str, list[str]]
124+
destination: CursorlessDestination, # pyright: ignore [reportGeneralTypeIssues]
125+
text: Union[str, list[str]],
124126
):
125127
"""Perform text insertion on Cursorless destination"""
126128
if isinstance(text, str):
127129
text = [text]
128130
cursorless_replace_action(destination, text)
129131

130132
def private_cursorless_action_or_ide_command(
131-
instruction: dict[str, str], target: CursorlessTarget
133+
instruction: dict[str, str], # pyright: ignore [reportGeneralTypeIssues]
134+
target: CursorlessTarget,
132135
):
133136
"""Perform cursorless action or ide command on target (internal use only)"""
134137
type = instruction["type"]

src/actions/bring_move.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def cursorless_bring_move_targets(m) -> BringMoveTargets:
3535

3636
@mod.action_class
3737
class Actions:
38-
def private_cursorless_bring_move(action_name: str, targets: BringMoveTargets):
38+
def private_cursorless_bring_move(action_name: str, targets: BringMoveTargets): # pyright: ignore [reportGeneralTypeIssues]
3939
"""Execute Cursorless move/bring action"""
4040
actions.user.private_cursorless_command_and_wait(
4141
{

src/actions/call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@mod.action_class
1010
class Actions:
1111
def private_cursorless_call(
12-
callee: CursorlessTarget,
12+
callee: CursorlessTarget, # pyright: ignore [reportGeneralTypeIssues]
1313
argument: CursorlessTarget = ImplicitTarget(),
1414
):
1515
"""Execute Cursorless call action"""

src/actions/get_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@mod.action_class
1111
class Actions:
1212
def cursorless_get_text(
13-
target: CursorlessTarget,
13+
target: CursorlessTarget, # pyright: ignore [reportGeneralTypeIssues]
1414
hide_decorations: bool = False,
1515
) -> str:
1616
"""Get target text. If hide_decorations is True, don't show decorations"""
@@ -21,7 +21,7 @@ def cursorless_get_text(
2121
)[0]
2222

2323
def cursorless_get_text_list(
24-
target: CursorlessTarget,
24+
target: CursorlessTarget, # pyright: ignore [reportGeneralTypeIssues]
2525
hide_decorations: bool = False,
2626
) -> list[str]:
2727
"""Get texts for multiple targets. If hide_decorations is True, don't show decorations"""

src/actions/homophones.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
from talon import actions, app
44

5-
from ..targets.target_types import CursorlessTarget, PrimitiveDestination
5+
from ..targets.target_types import (
6+
CursorlessExplicitTarget,
7+
PrimitiveDestination,
8+
)
69
from .get_text import cursorless_get_text_action
710
from .replace import cursorless_replace_action
811

912

10-
def cursorless_homophones_action(target: CursorlessTarget):
13+
def cursorless_homophones_action(target: CursorlessExplicitTarget):
1114
"""Replaced target with next homophone"""
1215
texts = cursorless_get_text_action(target, show_decorations=False)
1316
try:

src/actions/paste.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
@mod.action_class
1111
class Actions:
12-
def private_cursorless_paste(destination: CursorlessDestination):
12+
def private_cursorless_paste(
13+
destination: CursorlessDestination, # pyright: ignore [reportGeneralTypeIssues]
14+
):
1315
"""Execute Cursorless paste action"""
1416
actions.user.private_cursorless_command_and_wait(
1517
{

src/actions/reformat.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from talon import Module, actions
22

3-
from ..targets.target_types import CursorlessTarget, PrimitiveDestination
3+
from ..targets.target_types import (
4+
CursorlessExplicitTarget,
5+
PrimitiveDestination,
6+
)
47
from .get_text import cursorless_get_text_action
58
from .replace import cursorless_replace_action
69

@@ -11,7 +14,10 @@
1114

1215
@mod.action_class
1316
class Actions:
14-
def private_cursorless_reformat(target: CursorlessTarget, formatters: str):
17+
def private_cursorless_reformat(
18+
target: CursorlessExplicitTarget, # pyright: ignore [reportGeneralTypeIssues]
19+
formatters: str,
20+
):
1521
"""Execute Cursorless reformat action. Reformat target with formatter"""
1622
texts = cursorless_get_text_action(target, show_decorations=False)
1723
updated_texts = [actions.user.reformat_text(text, formatters) for text in texts]

src/actions/swap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def cursorless_swap_targets(m) -> SwapTargets:
3636

3737
@mod.action_class
3838
class Actions:
39-
def private_cursorless_swap(targets: SwapTargets):
39+
def private_cursorless_swap(
40+
targets: SwapTargets, # pyright: ignore [reportGeneralTypeIssues]
41+
):
4042
"""Execute Cursorless swap action"""
4143
actions.user.private_cursorless_command_and_wait(
4244
{

src/actions/wrap.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
@mod.action_class
1111
class Actions:
1212
def private_cursorless_wrap_with_paired_delimiter(
13-
action_name: str, target: CursorlessTarget, paired_delimiter: list[str]
13+
action_name: str, # pyright: ignore [reportGeneralTypeIssues]
14+
target: CursorlessTarget,
15+
paired_delimiter: list[str],
1416
):
1517
"""Execute Cursorless wrap/rewrap with paired delimiter action"""
1618
if action_name == "rewrap":
@@ -26,7 +28,9 @@ def private_cursorless_wrap_with_paired_delimiter(
2628
)
2729

2830
def private_cursorless_wrap_with_snippet(
29-
action_name: str, target: CursorlessTarget, snippet_location: str
31+
action_name: str, # pyright: ignore [reportGeneralTypeIssues]
32+
target: CursorlessTarget,
33+
snippet_location: str,
3034
):
3135
"""Execute Cursorless wrap with snippet action"""
3236
if action_name == "wrapWithPairedDelimiter":

src/apps/vscode_settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
class Actions:
2929
def vscode_settings_path() -> Path:
3030
"""Get path of vscode settings json file"""
31+
...
3132

32-
def vscode_get_setting(key: str, default_value: Any = None):
33+
def vscode_get_setting(key: str, default_value: Any = None): # pyright: ignore [reportGeneralTypeIssues]
3334
"""Get the value of vscode setting at the given key"""
3435
path: Path = actions.user.vscode_settings_path()
3536
settings: dict = loads(path.read_text())
@@ -40,7 +41,7 @@ def vscode_get_setting(key: str, default_value: Any = None):
4041
return settings[key]
4142

4243
def vscode_get_setting_with_fallback(
43-
key: str,
44+
key: str, # pyright: ignore [reportGeneralTypeIssues]
4445
default_value: Any,
4546
fallback_value: Any,
4647
fallback_message: str,

0 commit comments

Comments
 (0)