diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6c257088b8..f9ac046b40 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4f7e0ea79f..e2768df0f7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: # This is needed to get the number of commits in the current branch fetch-depth: 0 @@ -58,7 +58,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: # Deploy the exact commit that passed the test workflow. ref: ${{ github.event.workflow_run.head_sha }} @@ -72,7 +72,7 @@ jobs: CURSORLESS_DEPLOY: true - name: Checkout cursorless.nvim plugin repo - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: token: ${{ secrets.CURSORLESS_BOT_TOKEN }} repository: hands-free-vim/cursorless.nvim @@ -107,7 +107,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 token: ${{ secrets.CURSORLESS_BOT_TOKEN }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 8f51614507..bae47ac7b9 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -20,10 +20,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setup python - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version-file: "pyproject.toml" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0f78a81cf..5afe63ea66 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Set up Node.js uses: ./.github/actions/setup-node @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Set up Node.js uses: ./.github/actions/setup-node @@ -66,7 +66,7 @@ jobs: run: git config --global core.autocrlf false - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Set up Node.js uses: ./.github/actions/setup-node @@ -160,7 +160,7 @@ jobs: run: git config --global core.autocrlf false - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Set up Node.js uses: ./.github/actions/setup-node diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a57f57b718..4bbfc98410 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -98,7 +98,7 @@ repos: - id: ruff-format - repo: https://github.com/cursorless-dev/talon-tools - rev: v0.9.0 + rev: v0.11.2 hooks: - id: talon-fmt - id: tree-sitter-fmt diff --git a/cursorless-talon/src/actions/call.py b/cursorless-talon/src/actions/call.py index c0229ce9a4..106319a1b2 100644 --- a/cursorless-talon/src/actions/call.py +++ b/cursorless-talon/src/actions/call.py @@ -1,3 +1,5 @@ +from typing import Optional + from talon import Module, actions from ..targets.target_types import CursorlessTarget, ImplicitTarget @@ -11,13 +13,13 @@ class Actions: @staticmethod def private_cursorless_call( callee: CursorlessTarget, - argument: CursorlessTarget = ImplicitTarget(), + argument: Optional[CursorlessTarget] = None, ): """Execute Cursorless call action""" actions.user.private_cursorless_command_and_wait( { "name": "callAsFunction", "callee": callee, - "argument": argument, + "argument": argument or ImplicitTarget(), } ) diff --git a/cursorless-talon/src/actions/execute_command.py b/cursorless-talon/src/actions/execute_command.py index 067fc14488..4b0bed2636 100644 --- a/cursorless-talon/src/actions/execute_command.py +++ b/cursorless-talon/src/actions/execute_command.py @@ -1,17 +1,21 @@ +from typing import Optional + from talon import actions from ..targets.target_types import CursorlessTarget def cursorless_execute_command_action( - command_id: str, target: CursorlessTarget, command_options: dict = {} + command_id: str, + target: CursorlessTarget, + command_options: Optional[dict] = None, ): """Execute Cursorless execute command action""" actions.user.private_cursorless_command_and_wait( { "name": "executeCommand", "commandId": command_id, - "options": command_options, + "options": command_options or {}, "target": target, } ) diff --git a/cursorless-talon/src/apps/vscode_settings.py b/cursorless-talon/src/apps/vscode_settings.py index 8304051552..10fddeaaf0 100644 --- a/cursorless-talon/src/apps/vscode_settings.py +++ b/cursorless-talon/src/apps/vscode_settings.py @@ -37,8 +37,7 @@ def vscode_get_setting(key: str, default_value: Any = None): if default_value is not None: return settings.get(key, default_value) - else: - return settings[key] + return settings[key] @staticmethod def vscode_get_setting_with_fallback( diff --git a/cursorless-talon/src/csv_overrides.py b/cursorless-talon/src/csv_overrides.py index 57d78448d5..0041437784 100644 --- a/cursorless-talon/src/csv_overrides.py +++ b/cursorless-talon/src/csv_overrides.py @@ -210,7 +210,7 @@ def unsubscribe() -> None: def check_for_duplicates(filename: str, default_values: ListToSpokenForms): results_map = {} for list_name, values in default_values.items(): - for key, value in values.items(): + for _key, value in values.items(): if value in results_map: existing_list_name = results_map[value] warning = f"WARNING ({filename}): Value `{value}` duplicated between lists '{existing_list_name}' and '{list_name}'" @@ -233,7 +233,7 @@ def create_default_vocabulary_dicts( updated_dict: dict[str, str] = {} for key2, value2 in value.items(): # Enable deactivated(prefixed with a `-`) items - active_key = key2[1:] if key2.startswith("-") else key2 + active_key = key2.removeprefix("-") if active_key: updated_dict[active_key] = value2 default_values_updated[key] = updated_dict diff --git a/cursorless-talon/src/fallback.py b/cursorless-talon/src/fallback.py index f3c3541b29..cfd65de5b0 100644 --- a/cursorless-talon/src/fallback.py +++ b/cursorless-talon/src/fallback.py @@ -113,5 +113,5 @@ def get_modifier_callback(modifier: dict) -> Callable: def get_simple_modifier_callback(key: str) -> Callable: try: return modifier_callbacks[key] - except KeyError: - raise ValueError(f"Unknown Cursorless fallback modifier: {key}") + except KeyError as e: + raise ValueError(f"Unknown Cursorless fallback modifier: {key}") from e diff --git a/cursorless-talon/src/snippets/snippets.py b/cursorless-talon/src/snippets/snippets.py index 651e331bcd..dc240f5b23 100644 --- a/cursorless-talon/src/snippets/snippets.py +++ b/cursorless-talon/src/snippets/snippets.py @@ -38,7 +38,7 @@ class Actions: @staticmethod def cursorless_insert_snippet( body: str, - destination: CursorlessDestination = ImplicitDestination(), + destination: Optional[CursorlessDestination] = None, scope_type: Optional[Union[str, list[str]]] = None, ): """Cursorless: Insert custom snippet """ @@ -48,7 +48,7 @@ def cursorless_insert_snippet( languages=None, substitutions=None, ) - action = InsertSnippetAction(snippet, destination) + action = InsertSnippetAction(snippet, destination or ImplicitDestination()) actions.user.private_cursorless_command_and_wait(action) @staticmethod diff --git a/cursorless-talon/src/targets/destination.py b/cursorless-talon/src/targets/destination.py index 0c01864942..8e67d484fe 100644 --- a/cursorless-talon/src/targets/destination.py +++ b/cursorless-talon/src/targets/destination.py @@ -33,7 +33,9 @@ def cursorless_destination(m) -> Union[ListDestination, PrimitiveDestination]: destinations = [ PrimitiveDestination(insertion_mode, target) for insertion_mode, target in zip( - m.cursorless_insertion_mode_list, m.cursorless_target_list + m.cursorless_insertion_mode_list, + m.cursorless_target_list, + strict=True, ) ] diff --git a/pyproject.toml b/pyproject.toml index 57d1332569..1bdb262470 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,26 @@ target-version = "py311" extend-exclude = ["vendor", "resources/playground"] [tool.ruff.lint] -select = ["E", "F", "C4", "I001", "UP", "SIM", "FLY"] -ignore = ["E501", "SIM105", "UP007", "UP035", "UP045"] +select = [ + "E", # pycodestyle + "F", # Pyflakes + "UP", # pyupgrade + "B", # flake8-bugbear + "SIM", # flake8-simplify + "I", # isort + "C4", # Catch incorrect use of comprehensions, dict, list, etc + "ICN", # Use common import conventions + "RET", # Good return practices + "FURB", # Suggest more idiomatic Python patterns + "FLY", # Checks for str.join calls that can be replaced with f-strings. +] +ignore = [ + "E501", # Line too long + "SIM105", # Alow try-except-pass instead of contextlib.suppress({exception}) + "UP007", # Union[X, Y] -> X | Y not supported in Talon 0.4 actions + "UP045", # Optional[X] -> X | None not supported in Talon 0.4 actions + "UP035", # Deprecated import +] [tool.pyright] pythonVersion = "3.11"