From 5d814ca8c112f0dfa28770fcc8239f82adeb8ec5 Mon Sep 17 00:00:00 2001 From: Eric Cao Date: Mon, 8 Jun 2026 22:17:07 +0800 Subject: [PATCH] chore(api): convert RecommendAppRetrievalBase and WorkflowPauseEntity from ABC to Protocol (#37182) --- api/repositories/entities/workflow_pause.py | 19 +++++++------------ .../recommend_app/recommend_app_base.py | 16 +++++----------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/api/repositories/entities/workflow_pause.py b/api/repositories/entities/workflow_pause.py index 03ce574dca..4d9b680e5c 100644 --- a/api/repositories/entities/workflow_pause.py +++ b/api/repositories/entities/workflow_pause.py @@ -6,16 +6,16 @@ by the core workflow module. These models are independent of the storage mechani and don't contain implementation details like tenant_id, app_id, etc. """ -from abc import ABC, abstractmethod from collections.abc import Sequence from datetime import datetime +from typing import Protocol from graphon.entities.pause_reason import PauseReason -class WorkflowPauseEntity(ABC): +class WorkflowPauseEntity(Protocol): """ - Abstract base class for workflow pause entities. + Protocol for workflow pause entities. This domain model represents a paused workflow execution state, without implementation details like tenant_id, app_id, etc. @@ -27,19 +27,17 @@ class WorkflowPauseEntity(ABC): """ @property - @abstractmethod def id(self) -> str: """The identifier of current WorkflowPauseEntity""" - pass + ... @property - @abstractmethod def workflow_execution_id(self) -> str: """The identifier of the workflow execution record the pause associated with. Correspond to `WorkflowExecution.id`. """ + ... - @abstractmethod def get_state(self) -> bytes: """ Retrieve the serialized workflow state from storage. @@ -56,20 +54,17 @@ class WorkflowPauseEntity(ABC): ... @property - @abstractmethod def resumed_at(self) -> datetime | None: """`resumed_at` return the resumption time of the current pause, or `None` if the pause is not resumed yet. """ - pass + ... @property - @abstractmethod def paused_at(self) -> datetime: """`paused_at` returns the creation time of the pause.""" - pass + ... - @abstractmethod def get_pause_reasons(self) -> Sequence[PauseReason]: """ Retrieve detailed reasons for this pause. diff --git a/api/services/recommend_app/recommend_app_base.py b/api/services/recommend_app/recommend_app_base.py index 1f62fbf9d5..4214d56e4a 100644 --- a/api/services/recommend_app/recommend_app_base.py +++ b/api/services/recommend_app/recommend_app_base.py @@ -1,17 +1,11 @@ -from abc import ABC, abstractmethod +from typing import Any, Protocol -class RecommendAppRetrievalBase(ABC): +class RecommendAppRetrievalBase(Protocol): """Interface for recommend app retrieval.""" - @abstractmethod - def get_recommended_apps_and_categories(self, language: str): - raise NotImplementedError + def get_recommended_apps_and_categories(self, language: str) -> Any: ... - @abstractmethod - def get_recommend_app_detail(self, app_id: str): - raise NotImplementedError + def get_recommend_app_detail(self, app_id: str) -> Any: ... - @abstractmethod - def get_type(self) -> str: - raise NotImplementedError + def get_type(self) -> str: ...