Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 15, 2024
1 parent ea30b25 commit e97ed8b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import cv2
from cv2.typing import MatLike
from gen import about, design, settings, update_checker
from psutil import process_iter
from PySide6 import QtCore, QtGui
from PySide6.QtTest import QTest
Expand All @@ -44,7 +45,6 @@
from AutoControlledThread import AutoControlledThread
from AutoSplitImage import START_KEYWORD, AutoSplitImage, ImageType
from capture_method import CaptureMethodBase, CaptureMethodEnum
from gen import about, design, settings, update_checker
from hotkeys import (
HOTKEYS,
KEYBOARD_GROUPS_ISSUE,
Expand Down
24 changes: 16 additions & 8 deletions src/hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@
PRESS_A_KEY_TEXT = "Press a key..."

Commands = Literal["split", "start", "pause", "reset", "skip", "undo"]
Hotkey = Literal["split", "reset", "skip_split", "undo_split",
"pause", "screenshot", "toggle_auto_reset_image"]
Hotkey = Literal[
"split", "reset", "skip_split", "undo_split",
"pause", "screenshot", "toggle_auto_reset_image",
]
HOTKEYS = (
"split",
"reset",
"skip_split",
"undo_split",
"pause",
"screenshot",
"toggle_auto_reset_image")
"toggle_auto_reset_image",
)
HOTKEYS_WHEN_AUTOCONTROLLED = {"screenshot", "toggle_auto_reset_image"}


Expand Down Expand Up @@ -165,15 +168,18 @@ def __validate_keypad(expected_key: str, keyboard_event: keyboard.KeyboardEvent)
return not is_digit(expected_key[-1])


def _hotkey_action(keyboard_event: keyboard.KeyboardEvent,
key_name: str, action: Callable[[], None]):
def _hotkey_action(
keyboard_event: keyboard.KeyboardEvent,
key_name: str, action: Callable[[], None],
):
"""
We're doing the check here instead of saving the key code because
the non-keypad shared keys are localized while the keypad ones aren't.
They also share scan codes on Windows.
"""
if keyboard_event.event_type == keyboard.KEY_DOWN and __validate_keypad(
key_name, keyboard_event):
key_name, keyboard_event,
):
action()


Expand Down Expand Up @@ -305,7 +311,8 @@ def read_and_set_hotkey():
if hotkey_name == "esc":
_unhook(getattr(autosplit, f"{hotkey}_hotkey"))
autosplit.settings_dict[f"{hotkey}_hotkey"] = ( # pyright: ignore[reportGeneralTypeIssues]
"")
""
)
if autosplit.SettingsWidget:
getattr(autosplit.SettingsWidget, f"{hotkey}_input").setText("")
return
Expand Down Expand Up @@ -346,7 +353,8 @@ def read_and_set_hotkey():
if autosplit.SettingsWidget:
getattr(autosplit.SettingsWidget, f"{hotkey}_input").setText(hotkey_name)
autosplit.settings_dict[f"{hotkey}_hotkey"] = ( # pyright: ignore[reportGeneralTypeIssues]
hotkey_name)
hotkey_name
)
except Exception as exception: # noqa: BLE001 # We really want to catch everything here
error = exception
autosplit.show_error_signal.emit(lambda: error_messages.exception_traceback(error))
Expand Down
2 changes: 1 addition & 1 deletion src/menu_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from urllib.error import URLError
from urllib.request import urlopen

from gen import about, design, settings as settings_ui, update_checker
from packaging.version import parse as version_parse
from PySide6 import QtCore, QtWidgets
from PySide6.QtCore import Qt
Expand All @@ -22,7 +23,6 @@
change_capture_method,
get_all_video_capture_devices,
)
from gen import about, design, settings as settings_ui, update_checker
from hotkeys import HOTKEYS, HOTKEYS_WHEN_AUTOCONTROLLED, set_hotkey
from utils import AUTOSPLIT_VERSION, GITHUB_REPOSITORY, ONE_SECOND, decimal, fire_and_forget

Expand Down
2 changes: 1 addition & 1 deletion src/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from typing import TYPE_CHECKING, TypedDict, cast

import toml
from gen import design
from PySide6 import QtCore, QtWidgets
from typing_extensions import deprecated, override

import error_messages
from capture_method import CAPTURE_METHODS, CaptureMethodEnum, Region, change_capture_method
from gen import design
from hotkeys import HOTKEYS, Hotkey, remove_all_hotkeys, set_hotkey
from menu_bar import open_settings
from utils import auto_split_directory
Expand Down
1 change: 0 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import cv2
import numpy as np
from cv2.typing import MatLike

from gen.build_vars import AUTOSPLIT_BUILD_NUMBER, AUTOSPLIT_GITHUB_REPOSITORY

if sys.platform == "win32":
Expand Down

0 comments on commit e97ed8b

Please sign in to comment.