diff --git a/kiauh/components/webui_client/client_utils.py b/kiauh/components/webui_client/client_utils.py index dc93d04..e313e25 100644 --- a/kiauh/components/webui_client/client_utils.py +++ b/kiauh/components/webui_client/client_utils.py @@ -78,10 +78,10 @@ def get_current_client_config() -> str: installed = [c for c in clients if c.client_config.config_dir.exists()] if not installed: - return Color.apply("-", Color.CYAN) + return str(Color.apply("-", Color.CYAN)) elif len(installed) == 1: cfg = installed[0].client_config - return Color.apply(cfg.display_name, Color.CYAN) + return str(Color.apply(cfg.display_name, Color.CYAN)) # at this point, both client config folders exists, so we need to check # which are actually included in the printer.cfg of all klipper instances @@ -100,18 +100,18 @@ def get_current_client_config() -> str: # if both are included in the same file, we have a potential conflict if includes_mainsail and includes_fluidd: - return Color.apply("Conflict", Color.YELLOW) + return str(Color.apply("Conflict", Color.YELLOW)) if not mainsail_includes and not fluidd_includes: # there are no includes at all, even though the client config folders exist - return Color.apply("-", Color.CYAN) + return str(Color.apply("-", Color.CYAN)) elif len(fluidd_includes) > len(mainsail_includes): # there are more instances that include fluidd than mainsail - return Color.apply(fluidd.client_config.display_name, Color.CYAN) + return str(Color.apply(fluidd.client_config.display_name, Color.CYAN)) else: # there are the same amount of non-conflicting includes for each config # or more instances include mainsail than fluidd - return Color.apply(mainsail.client_config.display_name, Color.CYAN) + return str(Color.apply(mainsail.client_config.display_name, Color.CYAN)) def enable_mainsail_remotemode() -> None: @@ -445,9 +445,9 @@ def get_client_port_selection( while True: _type = "Reconfigure" if reconfigure else "Configure" question = f"{_type} {client.display_name} for port" - port_input = get_number_input(question, min_value=80, default=port) + port_input: int | None = get_number_input(question, min_value=80, default=port) - if port_input not in ports_in_use: + if port_input and port_input not in ports_in_use: client_settings: WebUiSettings = settings[client.name] client_settings.port = port_input settings.save() diff --git a/kiauh/components/webui_client/menus/client_install_menu.py b/kiauh/components/webui_client/menus/client_install_menu.py index 8a5aed1..142b713 100644 --- a/kiauh/components/webui_client/menus/client_install_menu.py +++ b/kiauh/components/webui_client/menus/client_install_menu.py @@ -97,7 +97,7 @@ class ClientInstallMenu(BaseMenu): self.message_service.set_message(message) def _get_current_port(self) -> int: - curr_port = get_nginx_listen_port(self.client.nginx_config) + curr_port: int | None = get_nginx_listen_port(self.client.nginx_config) if curr_port is None: # if the port is not found in the config file we use # the default port from the kiauh settings as fallback diff --git a/kiauh/utils/common.py b/kiauh/utils/common.py index 19ce776..13b3ffa 100644 --- a/kiauh/utils/common.py +++ b/kiauh/utils/common.py @@ -42,7 +42,7 @@ def get_kiauh_version() -> str: Helper method to get the current KIAUH version by reading the latest tag :return: string of the latest tag or a default value if no tags exist """ - tags = get_local_tags(Path(__file__).parent.parent) + tags: List[str] = get_local_tags(Path(__file__).parent.parent) if tags: return tags[-1] else: diff --git a/kiauh/utils/input_utils.py b/kiauh/utils/input_utils.py index 659a962..9c994ae 100644 --- a/kiauh/utils/input_utils.py +++ b/kiauh/utils/input_utils.py @@ -156,7 +156,7 @@ def format_question(question: str, default=None) -> str: if default is not None: formatted_q += f" (default={default})" - return Color.apply(f"###### {formatted_q}: ", Color.CYAN) + return str(Color.apply(f"###### {formatted_q}: ", Color.CYAN)) def validate_number_input(value: str, min_count: int, max_count: int | None) -> int: