diff --git a/kiauh/components/klipper/klipper_dialogs.py b/kiauh/components/klipper/klipper_dialogs.py index ada75b6..9964f66 100644 --- a/kiauh/components/klipper/klipper_dialogs.py +++ b/kiauh/components/klipper/klipper_dialogs.py @@ -9,7 +9,7 @@ import textwrap from enum import Enum, unique -from typing import List, Union, Literal +from typing import List from core.instance_manager.base_instance import BaseInstance from core.menus.base_menu import print_back_footer diff --git a/kiauh/components/log_uploads/log_upload_utils.py b/kiauh/components/log_uploads/log_upload_utils.py index 3a8029a..e54ca3a 100644 --- a/kiauh/components/log_uploads/log_upload_utils.py +++ b/kiauh/components/log_uploads/log_upload_utils.py @@ -50,5 +50,5 @@ def upload_logfile(logfile: LogFile) -> None: Logger.print_ok("Upload successful! Access it via the following link:") Logger.print_ok(f">>>> {link}", False) except Exception as e: - Logger.print_error(f"Uploading logfile failed!") + Logger.print_error("Uploading logfile failed!") Logger.print_error(str(e)) diff --git a/kiauh/components/webui_client/__init__.py b/kiauh/components/webui_client/__init__.py index 6f21f4a..bb87c0e 100644 --- a/kiauh/components/webui_client/__init__.py +++ b/kiauh/components/webui_client/__init__.py @@ -8,7 +8,7 @@ # ======================================================================= # from pathlib import Path -from typing import Literal, TypedDict, Set +from typing import Literal, TypedDict from core.backup_manager import BACKUP_ROOT_DIR diff --git a/kiauh/core/instance_manager/instance_manager.py b/kiauh/core/instance_manager/instance_manager.py index 0a5750b..07ecdd9 100644 --- a/kiauh/core/instance_manager/instance_manager.py +++ b/kiauh/core/instance_manager/instance_manager.py @@ -16,34 +16,34 @@ from core.instance_manager.base_instance import BaseInstance from utils.constants import SYSTEMD from utils.logger import Logger -I = TypeVar(name="I", bound=BaseInstance, covariant=True) +T = TypeVar(name="T", bound=BaseInstance, covariant=True) # noinspection PyMethodMayBeStatic class InstanceManager: - def __init__(self, instance_type: I) -> None: + def __init__(self, instance_type: T) -> None: self._instance_type = instance_type - self._current_instance: Optional[I] = None + self._current_instance: Optional[T] = None self._instance_suffix: Optional[str] = None self._instance_service: Optional[str] = None self._instance_service_full: Optional[str] = None self._instance_service_path: Optional[str] = None - self._instances: List[I] = [] + self._instances: List[T] = [] @property - def instance_type(self) -> I: + def instance_type(self) -> T: return self._instance_type @instance_type.setter - def instance_type(self, value: I): + def instance_type(self, value: T): self._instance_type = value @property - def current_instance(self) -> I: + def current_instance(self) -> T: return self._current_instance @current_instance.setter - def current_instance(self, value: I) -> None: + def current_instance(self, value: T) -> None: self._current_instance = value self.instance_suffix = value.suffix self.instance_service = value.get_service_file_name() @@ -78,11 +78,11 @@ class InstanceManager: self._instance_service_path = value @property - def instances(self) -> List[I]: + def instances(self) -> List[T]: return self.find_instances() @instances.setter - def instances(self, value: List[I]): + def instances(self, value: List[T]): self._instances = value def create_instance(self) -> None: @@ -182,7 +182,7 @@ class InstanceManager: Logger.print_error(f"{e}") raise - def find_instances(self) -> List[I]: + def find_instances(self) -> List[T]: name = self.instance_type.__name__.lower() pattern = re.compile(f"^{name}(-[0-9a-zA-Z]+)?.service$") excluded = self.instance_type.blacklist() diff --git a/kiauh/utils/filesystem_utils.py b/kiauh/utils/filesystem_utils.py index 0406bc2..86306bd 100644 --- a/kiauh/utils/filesystem_utils.py +++ b/kiauh/utils/filesystem_utils.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import os # ======================================================================= # # Copyright (C) 2020 - 2024 Dominik Willner # @@ -209,11 +208,10 @@ def add_config_section( cm.write_config() -def add_config_section_at_top( - section: str, - instances: List[B]): + +def add_config_section_at_top(section: str, instances: List[B]): for instance in instances: - tmp_cfg = tempfile.NamedTemporaryFile(mode="w" ,delete=False) + tmp_cfg = tempfile.NamedTemporaryFile(mode="w", delete=False) tmp_cfg_path = Path(tmp_cfg.name) cmt = ConfigManager(tmp_cfg_path) cmt.config.add_section(section)