Skip to content

Commit 006ea15

Browse files
Updated pyright config and silenced warnings (#3203)
1 parent 90c931e commit 006ea15

25 files changed

Lines changed: 124 additions & 100 deletions

.vscode/settings.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@
2828
".busted": "lua"
2929
},
3030
"files.eol": "\n",
31-
"github.copilot.chat.codeGeneration.instructions": [
32-
{
33-
"file": "./packages/cursorless-org-docs/src/docs/contributing/scope-test-format.md"
34-
}
35-
],
36-
"typescript.enablePromptUseWorkspaceTsdk": true,
37-
"typescript.tsdk": "node_modules/typescript/lib",
31+
"js/ts.tsdk.promptToUseWorkspaceVersion": true,
32+
"js/ts.tsdk": "node_modules/typescript/lib",
33+
"python.analysis.diagnosticMode": "workspace",
3834
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
39-
"typescript.tsc.autoDetect": "off"
35+
"js/ts.tsc.autoDetect": "off"
4036
}

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ When documenting actions or modifiers:
3636
- Many actions (`drop`, `float`, `puff`) work with both line and non-line targets
3737
- Always check test fixtures in `/data/fixtures/recorded/` to understand behavior
3838
- Implementation for many actions is in `/packages/cursorless-engine/src/actions/`
39+
- After running Python scripts or tests, delete any `__pycache__` directories and `.pyc` files created under the repository root.
3940

4041
## Scope test format
4142

cursorless-everywhere-talon/cursorless_everywhere_talon.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@
2424

2525
@ctx.action_class("user")
2626
class UserActions:
27+
@staticmethod
2728
def private_cursorless_run_rpc_command_and_wait(
28-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
29+
command_id: str,
2930
arg1: Any = None,
3031
arg2: Any = None,
3132
):
3233
actions.user.private_cursorless_talonjs_run_and_wait(command_id, arg1, arg2)
3334

35+
@staticmethod
3436
def private_cursorless_run_rpc_command_no_wait(
35-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
37+
command_id: str,
3638
arg1: Any = None,
3739
arg2: Any = None,
3840
):
3941
actions.user.private_cursorless_talonjs_run_no_wait(command_id, arg1, arg2)
4042

43+
@staticmethod
4144
def private_cursorless_run_rpc_command_get(
42-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
45+
command_id: str,
4346
arg1: Any = None,
4447
arg2: Any = None,
4548
) -> Any:
@@ -52,33 +55,32 @@ class Actions:
5255
def cursorless_everywhere_get_editor_state() -> EditorState: # pyright: ignore [reportReturnType]
5356
"""Get the focused editor element state"""
5457

55-
def cursorless_everywhere_set_selections(
56-
selections: list[SelectionOffsets], # pyright: ignore [reportGeneralTypeIssues]
57-
):
58+
@staticmethod
59+
def cursorless_everywhere_set_selections(selections: list[SelectionOffsets]):
5860
"""Set focused element selections"""
5961

60-
def cursorless_everywhere_edit_text(
61-
edit: EditorEdit, # pyright: ignore [reportGeneralTypeIssues]
62-
):
62+
@staticmethod
63+
def cursorless_everywhere_edit_text(edit: EditorEdit):
6364
"""Edit focused element text"""
6465

65-
def cursorless_everywhere_flash_ranges(
66-
ranges: list[RangeOffsets], # pyright: ignore [reportGeneralTypeIssues]
67-
):
66+
@staticmethod
67+
def cursorless_everywhere_flash_ranges(ranges: list[RangeOffsets]):
6868
"""Flash ranges in focused element"""
6969
actions.skip()
7070

7171
# Private actions
7272

73+
@staticmethod
7374
def private_cursorless_talonjs_run_and_wait(
74-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
75+
command_id: str,
7576
arg1: Any = None,
7677
arg2: Any = None,
7778
):
7879
"""Executes a Cursorless command, waits for its completion, but does not return the response"""
7980

81+
@staticmethod
8082
def private_cursorless_talonjs_run_no_wait(
81-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
83+
command_id: str,
8284
arg1: Any = None,
8385
arg2: Any = None,
8486
):

cursorless-everywhere-talon/cursorless_everywhere_talon_browser.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ def cursorless_everywhere_get_editor_state() -> EditorState:
3333
return actions.next()
3434
return res
3535

36-
def cursorless_everywhere_set_selections(
37-
selections: list[SelectionOffsets], # pyright: ignore [reportGeneralTypeIssues]
38-
):
36+
@staticmethod
37+
def cursorless_everywhere_set_selections(selections: list[SelectionOffsets]):
3938
command = {
4039
"id": "setSelections",
4140
"selections": [
@@ -47,9 +46,8 @@ def cursorless_everywhere_set_selections(
4746
if use_fallback(res):
4847
actions.next(selections)
4948

50-
def cursorless_everywhere_edit_text(
51-
edit: EditorEdit, # pyright: ignore [reportGeneralTypeIssues]
52-
):
49+
@staticmethod
50+
def cursorless_everywhere_edit_text(edit: EditorEdit):
5351
command = {
5452
"id": "editText",
5553
"text": edit["text"],
@@ -62,9 +60,8 @@ def cursorless_everywhere_edit_text(
6260
if use_fallback(res):
6361
actions.next(edit)
6462

65-
def cursorless_everywhere_flash_ranges(
66-
ranges: list[RangeOffsets], # pyright: ignore [reportGeneralTypeIssues]
67-
):
63+
@staticmethod
64+
def cursorless_everywhere_flash_ranges(ranges: list[RangeOffsets]):
6865
command = {
6966
"id": "flashRanges",
7067
"ranges": [

cursorless-everywhere-talon/cursorless_everywhere_talon_win.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
from talon import Context, app, ui
1+
import sys
2+
from typing import Any
3+
4+
from talon import Context, ui
25

36
from .cursorless_everywhere_talon import (
47
EditorEdit,
58
EditorState,
69
SelectionOffsets,
710
)
811

9-
if app.platform == "windows":
12+
if sys.platform == "win32":
1013
from talon.windows.ax import TextRange
14+
else:
15+
TextRange = Any
1116

1217

1318
# https://learn.microsoft.com/en-us/dotnet/api/system.windows.automation.text.textpatternrange?view=windowsdesktop-8.0
@@ -47,9 +52,8 @@ def cursorless_everywhere_get_editor_state() -> EditorState:
4752
"selections": selections,
4853
}
4954

50-
def cursorless_everywhere_set_selections(
51-
selections: list[SelectionOffsets], # pyright: ignore [reportGeneralTypeIssues]
52-
):
55+
@staticmethod
56+
def cursorless_everywhere_set_selections(selections: list[SelectionOffsets]):
5357
if selections.length != 1: # pyright: ignore [reportAttributeAccessIssue]
5458
raise ValueError("Only single selection supported")
5559

@@ -67,9 +71,8 @@ def cursorless_everywhere_set_selections(
6771

6872
set_selection(document_range, anchor, active)
6973

70-
def cursorless_everywhere_edit_text(
71-
edit: EditorEdit, # pyright: ignore [reportGeneralTypeIssues]
72-
):
74+
@staticmethod
75+
def cursorless_everywhere_edit_text(edit: EditorEdit):
7376
text = edit["text"]
7477

7578
el = ui.focused_element()

cursorless-talon-dev/src/spoken_form_test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,25 @@ class UserActions:
4545
def did_emit_pre_phrase_signal():
4646
return True
4747

48+
@staticmethod
4849
def private_cursorless_run_rpc_command_and_wait(
49-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
50+
command_id: str,
5051
arg1: Any,
5152
arg2: Any = None,
5253
):
5354
commands_run.append(arg1)
5455

56+
@staticmethod
5557
def private_cursorless_run_rpc_command_no_wait(
56-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
58+
command_id: str,
5759
arg1: Any,
5860
arg2: Any = None,
5961
):
6062
commands_run.append(arg1)
6163

64+
@staticmethod
6265
def private_cursorless_run_rpc_command_get(
63-
command_id: str, # pyright: ignore [reportGeneralTypeIssues]
66+
command_id: str,
6467
arg1: Any,
6568
arg2: Any = None,
6669
) -> Any:
@@ -70,7 +73,8 @@ def private_cursorless_run_rpc_command_get(
7073

7174
@mod.action_class
7275
class Actions:
73-
def private_cursorless_spoken_form_test_mode(enable: bool): # pyright: ignore [reportGeneralTypeIssues]
76+
@staticmethod
77+
def private_cursorless_spoken_form_test_mode(enable: bool):
7478
"""Enable/disable Cursorless spoken form test mode"""
7579
global saved_modes, saved_microphone
7680

@@ -97,8 +101,9 @@ def private_cursorless_spoken_form_test_mode(enable: bool): # pyright: ignore [
97101
"Cursorless spoken form tests are done. Talon microphone is re-enabled."
98102
)
99103

104+
@staticmethod
100105
def private_cursorless_spoken_form_test(
101-
phrase: str, # pyright: ignore [reportGeneralTypeIssues]
106+
phrase: str,
102107
mockedGetValue_: Optional[str],
103108
):
104109
"""Run Cursorless spoken form test"""

cursorless-talon/src/actions/actions.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def cursorless_action_or_ide_command(m) -> dict[str, str]:
8888

8989
@mod.action_class
9090
class Actions:
91-
def cursorless_command(action_name: str, target: CursorlessExplicitTarget): # pyright: ignore [reportGeneralTypeIssues]
91+
@staticmethod
92+
def cursorless_command(action_name: str, target: CursorlessExplicitTarget):
9293
"""Perform cursorless command on target"""
9394
if action_name in callback_actions:
9495
callback_actions[action_name](target)
@@ -109,29 +110,33 @@ def cursorless_command(action_name: str, target: CursorlessExplicitTarget): # p
109110
action = {"name": action_name, "target": target}
110111
actions.user.private_cursorless_command_and_wait(action)
111112

112-
def cursorless_vscode_command(command_id: str, target: CursorlessTarget): # pyright: ignore [reportGeneralTypeIssues]
113+
@staticmethod
114+
def cursorless_vscode_command(command_id: str, target: CursorlessTarget):
113115
"""
114116
Perform vscode command on cursorless target
115117
116118
Deprecated: prefer `cursorless_ide_command`
117119
"""
118120
return actions.user.cursorless_ide_command(command_id, target)
119121

120-
def cursorless_ide_command(command_id: str, target: CursorlessTarget): # pyright: ignore [reportGeneralTypeIssues]
122+
@staticmethod
123+
def cursorless_ide_command(command_id: str, target: CursorlessTarget):
121124
"""Perform ide command on cursorless target"""
122125
return cursorless_execute_command_action(command_id, target)
123126

127+
@staticmethod
124128
def cursorless_insert(
125-
destination: CursorlessDestination, # pyright: ignore [reportGeneralTypeIssues]
129+
destination: CursorlessDestination,
126130
text: Union[str, list[str]],
127131
):
128132
"""Perform text insertion on Cursorless destination"""
129133
if isinstance(text, str):
130134
text = [text]
131135
cursorless_replace_action(destination, text)
132136

137+
@staticmethod
133138
def private_cursorless_action_or_ide_command(
134-
instruction: dict[str, str], # pyright: ignore [reportGeneralTypeIssues]
139+
instruction: dict[str, str],
135140
target: CursorlessTarget,
136141
):
137142
"""Perform cursorless action or ide command on target (internal use only)"""

cursorless-talon/src/actions/bring_move.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ 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): # pyright: ignore [reportGeneralTypeIssues]
38+
@staticmethod
39+
def private_cursorless_bring_move(action_name: str, targets: BringMoveTargets):
3940
"""Execute Cursorless move/bring action"""
4041
actions.user.private_cursorless_command_and_wait(
4142
{

cursorless-talon/src/actions/call.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
@mod.action_class
1010
class Actions:
11+
@staticmethod
1112
def private_cursorless_call(
12-
callee: CursorlessTarget, # pyright: ignore [reportGeneralTypeIssues]
13+
callee: CursorlessTarget,
1314
argument: CursorlessTarget = ImplicitTarget(),
1415
):
1516
"""Execute Cursorless call action"""

cursorless-talon/src/actions/generate_snippet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
@mod.action_class
1212
class Actions:
13-
def private_cursorless_generate_snippet_action(target: CursorlessExplicitTarget): # pyright: ignore [reportGeneralTypeIssues]
13+
@staticmethod
14+
def private_cursorless_generate_snippet_action(target: CursorlessExplicitTarget):
1415
"""Generate a snippet from the given target"""
1516
actions.user.private_cursorless_command_no_wait(
1617
{

0 commit comments

Comments
 (0)