Skip to content

Commit

Permalink
Added more Ruff checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfmanstout committed Nov 11, 2024
1 parent d5f222d commit 8682b2e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
19 changes: 10 additions & 9 deletions gaze_ocr_talon.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import glob
import logging
import sys
from collections.abc import Iterable, Sequence
from math import floor
from pathlib import Path
from typing import Dict, Iterable, Literal, Optional, Sequence
from typing import Literal, Optional

import numpy as np
from talon import Context, Module, actions, app, cron, fs, screen, settings
Expand Down Expand Up @@ -146,7 +147,7 @@


def add_homophones(
homophones: Dict[str, Sequence[str]], to_add: Iterable[Iterable[str]]
homophones: dict[str, Sequence[str]], to_add: Iterable[Iterable[str]]
):
for words in to_add:
merged_words = set(words)
Expand Down Expand Up @@ -394,7 +395,7 @@ def move_cursor_to_word_generator(text: TimestampedText):
)
if not result:
actions.user.show_ocr_overlay_for_query("text", f"{text.text}")
raise RuntimeError('Unable to find: "{}"'.format(text))
raise RuntimeError(f'Unable to find: "{text}"')


def move_text_cursor_to_word_generator(
Expand All @@ -412,7 +413,7 @@ def move_text_cursor_to_word_generator(
)
if not result:
actions.user.show_ocr_overlay_for_query("text", f"{text.text}")
raise RuntimeError('Unable to find: "{}"'.format(text))
raise RuntimeError(f'Unable to find: "{text}"')


def move_text_cursor_to_longest_prefix_generator(
Expand All @@ -431,7 +432,7 @@ def move_text_cursor_to_longest_prefix_generator(
)
if not locations:
actions.user.show_ocr_overlay_for_query("text", f"{text.text}")
raise RuntimeError('Unable to find: "{}"'.format(text))
raise RuntimeError(f'Unable to find: "{text}"')
return prefix_length


Expand All @@ -451,7 +452,7 @@ def move_text_cursor_to_longest_suffix_generator(
)
if not locations:
actions.user.show_ocr_overlay_for_query("text", f"{text.text}")
raise RuntimeError('Unable to find: "{}"'.format(text))
raise RuntimeError(f'Unable to find: "{text}"')
return prefix_length


Expand All @@ -464,7 +465,7 @@ def move_text_cursor_to_difference(text: TimestampedText):
)
if not result:
actions.user.show_ocr_overlay_for_query("text", f"{text.text}")
raise RuntimeError('Unable to find: "{}"'.format(text))
raise RuntimeError(f'Unable to find: "{text}"')
return result


Expand Down Expand Up @@ -493,7 +494,7 @@ def select_text_generator(
actions.user.show_ocr_overlay_for_query(
"text", f"{start.text}...{end.text if end else None}"
)
raise RuntimeError('Unable to select "{}" to "{}"'.format(start, end))
raise RuntimeError(f'Unable to select "{start}" to "{end}"')


def select_matching_text_generator(text: TimestampedText):
Expand All @@ -506,7 +507,7 @@ def select_matching_text_generator(text: TimestampedText):
)
if not result:
actions.user.show_ocr_overlay_for_query("text", f"{text.text}")
raise RuntimeError('Unable to find: "{}"'.format(text))
raise RuntimeError(f'Unable to find: "{text}"')


def perform_ocr_action_generator(
Expand Down
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "talon-gaze-ocr"
version = "0.1.0"
description = "Talon scripts to enable advanced cursor control using eye tracking and text recognition (OCR)."
readme = "README.md"
requires-python = ">=3.11"
dependencies = []

[tool.ruff.lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
]
ignore = ["E501", "SIM105", "SIM116", "UP007"]

[tool.pyright]
reportSelfClsParameterName = false

0 comments on commit 8682b2e

Please sign in to comment.