Skip to content

Commit 6a92dc5

Browse files
committed
Introduce shared base context class
1 parent 14996ca commit 6a92dc5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

temporalio/converter.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ class SerializationContext(ABC):
8989

9090

9191
@dataclass(frozen=True)
92-
class WorkflowSerializationContext(SerializationContext):
92+
class BaseWorkflowSerializationContext(SerializationContext):
93+
"""Base serialization context shared by workflow and activity serialization contexts."""
94+
95+
namespace: str
96+
workflow_id: str
97+
98+
99+
@dataclass(frozen=True)
100+
class WorkflowSerializationContext(BaseWorkflowSerializationContext):
93101
"""Serialization context for workflows.
94102
95103
See :py:class:`SerializationContext` for more details.
@@ -102,29 +110,26 @@ class WorkflowSerializationContext(SerializationContext):
102110
when the workflow is created by the schedule.
103111
"""
104112

105-
namespace: str
106-
workflow_id: str
113+
pass
107114

108115

109116
@dataclass(frozen=True)
110-
class ActivitySerializationContext(SerializationContext):
117+
class ActivitySerializationContext(BaseWorkflowSerializationContext):
111118
"""Serialization context for activities.
112119
113120
See :py:class:`SerializationContext` for more details.
114121
115122
Attributes:
116123
namespace: Workflow/activity namespace.
117124
workflow_id: Workflow ID. Note, when creating/describing schedules,
118-
this may be the workflow ID prefix as configured, not the final
119-
workflow ID when the workflow is created by the schedule.
125+
this may be the workflow ID prefix as configured, not the final workflow ID when the
126+
workflow is created by the schedule.
120127
workflow_type: Workflow Type.
121128
activity_type: Activity Type.
122129
activity_task_queue: Activity task queue.
123130
is_local: Whether the activity is a local activity.
124131
"""
125132

126-
namespace: str
127-
workflow_id: str
128133
workflow_type: str
129134
activity_type: str
130135
activity_task_queue: str

0 commit comments

Comments
 (0)