chore(api): fix mypy violations

pull/22621/head
QuantumGhost 10 months ago
parent d50bdc1d70
commit 71aa34dcce

@ -21,7 +21,9 @@ class _CommandTag(StrEnum):
CONTINUE = "continue" CONTINUE = "continue"
class Command(BaseModel, abc.ABC): # Note: Avoid using the `_Command` class directly.
# Instead, use `CommandTypes` for type annotations.
class _Command(BaseModel, abc.ABC):
model_config = ConfigDict(frozen=True) model_config = ConfigDict(frozen=True)
tag: _CommandTag tag: _CommandTag
@ -35,21 +37,21 @@ class Command(BaseModel, abc.ABC):
@final @final
class StopCommand(Command): class StopCommand(_Command):
tag: _CommandTag = _CommandTag.STOP tag: _CommandTag = _CommandTag.STOP
@final @final
class SuspendCommand(Command): class SuspendCommand(_Command):
tag: _CommandTag = _CommandTag.SUSPEND tag: _CommandTag = _CommandTag.SUSPEND
@final @final
class ContinueCommand(Command): class ContinueCommand(_Command):
tag: _CommandTag = _CommandTag.CONTINUE tag: _CommandTag = _CommandTag.CONTINUE
def _get_command_tag(command: Command): def _get_command_tag(command: _Command):
return command.tag return command.tag

@ -57,7 +57,14 @@ from core.workflow.utils import variable_utils
from libs.flask_utils import preserve_flask_contexts from libs.flask_utils import preserve_flask_contexts
from models.workflow import WorkflowType from models.workflow import WorkflowType
from .command_source import Command, CommandParams, CommandSource, ContinueCommand, StopCommand, SuspendCommand from .command_source import (
CommandParams,
CommandSource,
CommandTypes,
ContinueCommand,
StopCommand,
SuspendCommand,
)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -89,7 +96,7 @@ class GraphEngineThreadPool(ThreadPoolExecutor):
raise ValueError(f"Max submit count {self.max_submit_count} of workflow thread pool reached.") raise ValueError(f"Max submit count {self.max_submit_count} of workflow thread pool reached.")
def _default_source(params: CommandParams) -> Command: def _default_source(_: CommandParams) -> CommandTypes:
return ContinueCommand() return ContinueCommand()

Loading…
Cancel
Save