From 224f4267651bf43c3fab7d203262940b95dc41b0 Mon Sep 17 00:00:00 2001 From: hjlarry Date: Sun, 18 Jan 2026 10:07:46 +0800 Subject: [PATCH] fix CI --- api/services/workflow_comment_service.py | 27 ++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/api/services/workflow_comment_service.py b/api/services/workflow_comment_service.py index ac20a87c31..4ae3989393 100644 --- a/api/services/workflow_comment_service.py +++ b/api/services/workflow_comment_service.py @@ -1,5 +1,6 @@ import logging from collections.abc import Sequence +from typing import Protocol, cast from sqlalchemy import desc, select from sqlalchemy.orm import Session, selectinload @@ -14,6 +15,19 @@ from models.account import Account logger = logging.getLogger(__name__) +class _CommentAccountCache(Protocol): + _created_by_account_cache: Account | None + _resolved_by_account_cache: Account | None + + +class _ReplyAccountCache(Protocol): + _created_by_account_cache: Account | None + + +class _MentionAccountCache(Protocol): + _mentioned_user_account_cache: Account | None + + class WorkflowCommentService: """Service for managing workflow comments.""" @@ -65,12 +79,17 @@ class WorkflowCommentService: # Cache accounts on objects for comment in comments: - comment._created_by_account_cache = account_map.get(comment.created_by) - comment._resolved_by_account_cache = account_map.get(comment.resolved_by) if comment.resolved_by else None + comment_cache = cast(_CommentAccountCache, comment) + comment_cache._created_by_account_cache = account_map.get(comment.created_by) + comment_cache._resolved_by_account_cache = ( + account_map.get(comment.resolved_by) if comment.resolved_by else None + ) for reply in comment.replies: - reply._created_by_account_cache = account_map.get(reply.created_by) + reply_cache = cast(_ReplyAccountCache, reply) + reply_cache._created_by_account_cache = account_map.get(reply.created_by) for mention in comment.mentions: - mention._mentioned_user_account_cache = account_map.get(mention.mentioned_user_id) + mention_cache = cast(_MentionAccountCache, mention) + mention_cache._mentioned_user_account_cache = account_map.get(mention.mentioned_user_id) @staticmethod def get_comment(tenant_id: str, app_id: str, comment_id: str, session: Session | None = None) -> WorkflowComment: