From 3758744eb67d4ec1175d9b91665211a80ae36e8e Mon Sep 17 00:00:00 2001 From: anonCantCode <133663594+anonCantCode@users.noreply.github.com> Date: Sat, 20 May 2023 06:27:12 +0530 Subject: [PATCH 1/2] Use Optional[] to preserve Python 3.9 compatability --- modules/shared.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/shared.py b/modules/shared.py index fa0804585..80160468b 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -15,6 +15,7 @@ import modules.devices as devices from modules import localization, script_loading, errors, ui_components, shared_items, cmd_args from modules.paths_internal import models_path, script_path, data_path, sd_configs_path, sd_default_config, sd_model_file, default_sd_model_file, extensions_dir, extensions_builtin_dir # noqa: F401 from ldm.models.diffusion.ddpm import LatentDiffusion +from typing import Optional demo = None @@ -113,7 +114,7 @@ class State: time_start = None server_start = None _server_command_signal = threading.Event() - _server_command: str | None = None + _server_command: Optional[str] @property def need_restart(self) -> bool: @@ -131,14 +132,14 @@ class State: return self._server_command @server_command.setter - def server_command(self, value: str | None) -> None: + def server_command(self, value: Optional[str]) -> None: """ Set the server command to `value` and signal that it's been set. """ self._server_command = value self._server_command_signal.set() - def wait_for_server_command(self, timeout: float | None = None) -> str | None: + def wait_for_server_command(self, timeout: Optional[float]) -> Optional[str]: """ Wait for server command to get set; return and clear the value and signal. """ From 0b6ca8e77b498a2a6fd0161f7d296a0b49c4358b Mon Sep 17 00:00:00 2001 From: anonCantCode <133663594+anonCantCode@users.noreply.github.com> Date: Sat, 20 May 2023 11:13:03 +0530 Subject: [PATCH 2/2] preserve declarations --- modules/shared.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/shared.py b/modules/shared.py index 80160468b..e53b1e113 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -114,7 +114,7 @@ class State: time_start = None server_start = None _server_command_signal = threading.Event() - _server_command: Optional[str] + _server_command: Optional[str] = None @property def need_restart(self) -> bool: @@ -139,7 +139,7 @@ class State: self._server_command = value self._server_command_signal.set() - def wait_for_server_command(self, timeout: Optional[float]) -> Optional[str]: + def wait_for_server_command(self, timeout: Optional[float] = None) -> Optional[str]: """ Wait for server command to get set; return and clear the value and signal. """