From e3c2345b21766fd7da31899d27e724575ab9628a Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Sat, 18 Oct 2025 20:17:23 +0800 Subject: [PATCH] fix: typing --- api/services/async_workflow_service.py | 12 +++++++----- api/services/trigger/webhook_service.py | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/api/services/async_workflow_service.py b/api/services/async_workflow_service.py index b3074be296..e7618686c5 100644 --- a/api/services/async_workflow_service.py +++ b/api/services/async_workflow_service.py @@ -7,7 +7,7 @@ with support for different subscription tiers, rate limiting, and execution trac import json from datetime import UTC, datetime -from typing import Optional, Union +from typing import Any, Optional, Union from celery.result import AsyncResult from sqlalchemy import select @@ -152,7 +152,7 @@ class AsyncWorkflowService: # 9. Dispatch to appropriate queue task_data_dict = task_data.model_dump(mode="json") - task: AsyncResult | None = None + task: AsyncResult[Any] | None = None if queue_name == QueuePriority.PROFESSIONAL: task = execute_workflow_professional.delay(task_data_dict) # type: ignore elif queue_name == QueuePriority.TEAM: @@ -226,7 +226,7 @@ class AsyncWorkflowService: return cls.trigger_workflow_async(session, user, trigger_data) @classmethod - def get_trigger_log(cls, workflow_trigger_log_id: str, tenant_id: Optional[str] = None) -> Optional[dict]: + def get_trigger_log(cls, workflow_trigger_log_id: str, tenant_id: Optional[str] = None) -> Optional[dict[str, Any]]: """ Get trigger log by ID @@ -249,7 +249,7 @@ class AsyncWorkflowService: @classmethod def get_recent_logs( cls, tenant_id: str, app_id: str, hours: int = 24, limit: int = 100, offset: int = 0 - ) -> list[dict]: + ) -> list[dict[str, Any]]: """ Get recent trigger logs @@ -272,7 +272,9 @@ class AsyncWorkflowService: return [log.to_dict() for log in logs] @classmethod - def get_failed_logs_for_retry(cls, tenant_id: str, max_retry_count: int = 3, limit: int = 100) -> list[dict]: + def get_failed_logs_for_retry( + cls, tenant_id: str, max_retry_count: int = 3, limit: int = 100 + ) -> list[dict[str, Any]]: """ Get failed logs eligible for retry diff --git a/api/services/trigger/webhook_service.py b/api/services/trigger/webhook_service.py index d661c39a7b..3e6686119f 100644 --- a/api/services/trigger/webhook_service.py +++ b/api/services/trigger/webhook_service.py @@ -9,6 +9,7 @@ from flask import request from pydantic import BaseModel from sqlalchemy import select from sqlalchemy.orm import Session +from werkzeug.datastructures import FileStorage from werkzeug.exceptions import RequestEntityTooLarge from configs import dify_config @@ -324,7 +325,9 @@ class WebhookService: return body, {} @classmethod - def _process_file_uploads(cls, files, webhook_trigger: WorkflowWebhookTrigger) -> dict[str, Any]: + def _process_file_uploads( + cls, files: Mapping[str, FileStorage], webhook_trigger: WorkflowWebhookTrigger + ) -> dict[str, Any]: """Process file uploads using ToolFileManager. Args: