Skip to content

Commit 57b1c31

Browse files
committed
Revert "Cleanup"
This reverts commit 8fe8e55.
1 parent 8fe8e55 commit 57b1c31

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

temporalio/worker/_command_aware_visitor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import contextvars
44
from contextlib import contextmanager
55
from dataclasses import dataclass
6-
from typing import Iterator, Optional
6+
from typing import Any, Iterator, Optional, Type
77

88
from temporalio.api.enums.v1.command_type_pb2 import CommandType
99
from temporalio.bridge._visitor import PayloadVisitor, VisitorFunctions
10+
from temporalio.bridge.proto.workflow_activation import workflow_activation_pb2
1011
from temporalio.bridge.proto.workflow_activation.workflow_activation_pb2 import (
1112
ResolveActivity,
1213
ResolveChildWorkflowExecution,
@@ -16,6 +17,7 @@
1617
ResolveRequestCancelExternalWorkflow,
1718
ResolveSignalExternalWorkflow,
1819
)
20+
from temporalio.bridge.proto.workflow_commands import workflow_commands_pb2
1921
from temporalio.bridge.proto.workflow_commands.workflow_commands_pb2 import (
2022
ScheduleActivity,
2123
ScheduleLocalActivity,
@@ -150,11 +152,11 @@ async def _visit_coresdk_workflow_activation_ResolveNexusOperation(
150152

151153
@contextmanager
152154
def current_command(
153-
command_type: CommandType.ValueType, command_seq: int
155+
command_type: Optional[CommandType.ValueType], command_seq: int
154156
) -> Iterator[None]:
155157
"""Context manager for setting command info."""
156158
token = current_command_info.set(
157-
CommandInfo(command_type=command_type, command_seq=command_seq)
159+
CommandInfo(command_type=command_type, command_seq=command_seq) # type: ignore
158160
)
159161
try:
160162
yield

tests/worker/test_command_aware_visitor.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Test that CommandAwarePayloadVisitor handles all commands with seq fields that have payloads."""
22

3+
from typing import Any, Iterator, Type
4+
35
from temporalio.bridge._visitor import PayloadVisitor
4-
from temporalio.worker._command_aware_visitor import (
5-
CommandAwarePayloadVisitor,
6-
_get_workflow_activation_job_protos_with_seq,
7-
_get_workflow_command_protos_with_seq,
8-
)
6+
from temporalio.bridge.proto.workflow_activation import workflow_activation_pb2
7+
from temporalio.bridge.proto.workflow_commands import workflow_commands_pb2
8+
from temporalio.worker._command_aware_visitor import CommandAwarePayloadVisitor
99

1010

1111
def test_command_aware_visitor_has_methods_for_all_seq_protos_with_payloads():
@@ -73,3 +73,17 @@ def test_command_aware_visitor_has_methods_for_all_seq_protos_with_payloads():
7373
assert (
7474
len(jobs_with_payloads) == len(job_protos) - 1
7575
), "Should have exactly one activation job without payloads (FireTimer)"
76+
77+
78+
def _get_workflow_command_protos_with_seq() -> Iterator[Type[Any]]:
79+
"""Get concrete classes of all workflow command protos with a seq field."""
80+
for descriptor in workflow_commands_pb2.DESCRIPTOR.message_types_by_name.values():
81+
if "seq" in descriptor.fields_by_name:
82+
yield descriptor._concrete_class
83+
84+
85+
def _get_workflow_activation_job_protos_with_seq() -> Iterator[Type[Any]]:
86+
"""Get concrete classes of all workflow activation job protos with a seq field."""
87+
for descriptor in workflow_activation_pb2.DESCRIPTOR.message_types_by_name.values():
88+
if "seq" in descriptor.fields_by_name:
89+
yield descriptor._concrete_class

0 commit comments

Comments
 (0)