From 4fa46de9a8bf8016264f62d7b0acb7d977c2f202 Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:37:23 +0100 Subject: [PATCH] Switch from black to ruff (#2306) See https://docs.astral.sh/ruff/formatter/ ## 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 --- .pre-commit-config.yaml | 7 ++----- .vscode/settings.json | 2 +- cursorless-talon/src/marks/decorated_mark.py | 2 +- cursorless-talon/src/private_api/private_api.py | 2 +- pyproject.toml | 6 ++++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b66576314f..33c376f87b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -76,11 +76,8 @@ repos: hooks: - id: flynt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.11 + rev: v0.4.1 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.1.1 - hooks: - - id: black + - id: ruff-format diff --git a/.vscode/settings.json b/.vscode/settings.json index 96ba760122..7380c4f033 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ // Place your settings in this file to overwrite default and user settings. { "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter" + "editor.defaultFormatter": "charliermarsh.ruff" }, "[scm]": { "editor.defaultFormatter": "AndreasArvidsson.andreas-talon" diff --git a/cursorless-talon/src/marks/decorated_mark.py b/cursorless-talon/src/marks/decorated_mark.py index 2eaa338f52..3592d4f6cc 100644 --- a/cursorless-talon/src/marks/decorated_mark.py +++ b/cursorless-talon/src/marks/decorated_mark.py @@ -23,7 +23,7 @@ def cursorless_grapheme(m) -> str: except AttributeError: # NB: This represents unknown char in Unicode. It will be translated # to "[unk]" by Cursorless extension. - return "\uFFFD" + return "\ufffd" @mod.capture( diff --git a/cursorless-talon/src/private_api/private_api.py b/cursorless-talon/src/private_api/private_api.py index d6fd88e779..dd047e2108 100644 --- a/cursorless-talon/src/private_api/private_api.py +++ b/cursorless-talon/src/private_api/private_api.py @@ -31,7 +31,7 @@ def cursorless_private_build_primitive_target( return PrimitiveTarget(mark, modifiers) def cursorless_private_build_list_target( - elements: list[Union[PrimitiveTarget, RangeTarget]] + elements: list[Union[PrimitiveTarget, RangeTarget]], ) -> Union[PrimitiveTarget, ListTarget]: """Cursorless private api low-level target builder: Create a list target""" if len(elements) == 1: diff --git a/pyproject.toml b/pyproject.toml index 8b383b8011..e537f0d8c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,10 +8,12 @@ force-exclude = ''' ''' [tool.ruff] -select = ["E", "F", "C4", "I001", "UP", "SIM"] -ignore = ["E501", "SIM105", "UP007", "UP035"] target-version = "py311" extend-exclude = ["vendor", "data/playground/**/*.py"] +[tool.ruff.lint] +select = ["E", "F", "C4", "I001", "UP", "SIM"] +ignore = ["E501", "SIM105", "UP007", "UP035"] + [tool.pyright] reportSelfClsParameterName = false