Files
MoviePilot/app/workflow/actions/send_event.py
jxxghp 6d4ce83837 fix(types): clear host mypy debt and prevent typing regressions
严格检查全部宿主源码,清零类型错误预算并移除按模块类型豁免。
按原因、所属方法、错误码及语法指纹锁定必要兼容例外和站点类型桩,
CI 阻断新增忽略、检查范围退化、本地桩替代真实接口及新的类型错误。

修复空值、异步和供应方类型边界,保持插件与 API 兼容合同,
并补充存储、订阅、通知、Agent 和工作流边界的回归覆盖。
2026-10-21 22:03:18 +08:00

49 lines
1.2 KiB
Python

"""
向事件总线发送工作流执行事件。
"""
from app.runtime.events import eventmanager
from app.schemas.types import ChainEventType
from app.schemas.workflow import ActionContext, ActionParams
from app.workflow.actions import BaseAction
class SendEventParams(ActionParams):
"""
发送事件参数
"""
pass
class SendEventAction(BaseAction):
"""
发送事件
"""
contract = {}
name = "发送事件"
description = "发送任务执行事件"
data = SendEventParams().model_dump()
@property
def success(self) -> bool:
"""
返回动作是否已标记为完成。
:return: 动作完成标志的当前值
"""
return self.done
def execute(self, workflow_id: int, params: dict[str, object], context: ActionContext) -> ActionContext:
"""
发送工作流事件,以更插件干预工作流执行
"""
# 触发资源下载事件,更新执行上下文
event = eventmanager.send_event(ChainEventType.WorkflowExecution, context.model_dump())
if event and isinstance(event.event_data, ActionContext):
context = event.event_data
self.job_done()
return context