Skip to content

Commit f06ffbb

Browse files
committed
Clean up existing code
1 parent 92b7758 commit f06ffbb

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

temporalio/worker/_interceptor.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -388,23 +388,23 @@ async def signal_external_workflow(
388388

389389
def start_activity(
390390
self, input: StartActivityInput
391-
) -> temporalio.workflow.ActivityHandle:
391+
) -> temporalio.workflow.ActivityHandle[Any]:
392392
"""Called for every :py:func:`temporalio.workflow.start_activity` and
393393
:py:func:`temporalio.workflow.execute_activity` call.
394394
"""
395395
return self.next.start_activity(input)
396396

397397
async def start_child_workflow(
398398
self, input: StartChildWorkflowInput
399-
) -> temporalio.workflow.ChildWorkflowHandle:
399+
) -> temporalio.workflow.ChildWorkflowHandle[Any, Any]:
400400
"""Called for every :py:func:`temporalio.workflow.start_child_workflow`
401401
and :py:func:`temporalio.workflow.execute_child_workflow` call.
402402
"""
403403
return await self.next.start_child_workflow(input)
404404

405405
def start_local_activity(
406406
self, input: StartLocalActivityInput
407-
) -> temporalio.workflow.ActivityHandle:
407+
) -> temporalio.workflow.ActivityHandle[Any]:
408408
"""Called for every :py:func:`temporalio.workflow.start_local_activity`
409409
and :py:func:`temporalio.workflow.execute_local_activity` call.
410410
"""

temporalio/worker/_workflow_instance.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1582,12 +1582,10 @@ async def _outbound_signal_external_workflow(
15821582
async def _outbound_start_child_workflow(
15831583
self, input: StartChildWorkflowInput
15841584
) -> _ChildWorkflowHandle:
1585-
handle: Optional[_ChildWorkflowHandle] = None
1585+
handle: _ChildWorkflowHandle
15861586

15871587
# Common code for handling cancel for start and run
15881588
def apply_child_cancel_error() -> None:
1589-
nonlocal handle
1590-
assert handle
15911589
# Send a cancel request to the child
15921590
cancel_command = self._add_command()
15931591
handle._apply_cancel_command(cancel_command)
@@ -1605,9 +1603,7 @@ def apply_child_cancel_error() -> None:
16051603

16061604
# Function that runs in the handle
16071605
async def run_child() -> Any:
1608-
nonlocal handle
16091606
while True:
1610-
assert handle
16111607
try:
16121608
# We have to shield because we don't want the future itself
16131609
# to be cancelled

tests/helpers/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import uuid
55
from contextlib import closing
66
from datetime import timedelta
7-
from typing import Any, Awaitable, Callable, Optional, Sequence, Type, TypeVar, Union
7+
from typing import Any, Awaitable, Callable, Optional, Sequence, Type, TypeVar
88

99
from temporalio.api.common.v1 import WorkflowExecution
1010
from temporalio.api.enums.v1 import IndexedValueType

0 commit comments

Comments
 (0)