From 40cc63aa8a4e1733c7f59dff1fa056230e3c2d27 Mon Sep 17 00:00:00 2001 From: James Stout Date: Sat, 26 Oct 2024 16:01:09 -0700 Subject: [PATCH] Added Ruff pre-commit. --- .pre-commit-config.yaml | 13 +++++++++++++ gaze_ocr_talon.py | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fd4aa99 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: '^.subtrees/(jarowinkler|rapidfuzz)/' +repos: +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.7.1 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format diff --git a/gaze_ocr_talon.py b/gaze_ocr_talon.py index d8e7dee..a2e355e 100644 --- a/gaze_ocr_talon.py +++ b/gaze_ocr_talon.py @@ -198,7 +198,7 @@ def add_homophones( if homophones_file: logging.info(f"Found homophones file: {homophones_file}") else: - logging.warning(f"Could not find homophones.csv. Is knausj_talon installed?") + logging.warning("Could not find homophones.csv. Is knausj_talon installed?") def get_knausj_homophones(): @@ -310,7 +310,11 @@ def get_debug_color(has_light_background: bool): def reset_disambiguation(): - global ambiguous_matches, disambiguation_generator, disambiguation_canvas, debug_canvas + global \ + ambiguous_matches, \ + disambiguation_generator, \ + disambiguation_canvas, \ + debug_canvas ambiguous_matches = None disambiguation_generator = None hide_canvas = disambiguation_canvas or debug_canvas