Skip to content

Commit 5d759c3

Browse files
committed
lint
Signed-off-by: Tim Li <[email protected]>
1 parent 7818de9 commit 5d759c3

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

cadence/_internal/workflow/workflow_engine.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from typing import Optional, Callable, Any
23

34
from cadence._internal.workflow.context import Context
45
from cadence.api.v1.decision_pb2 import Decision
@@ -10,12 +11,15 @@
1011
@dataclass
1112
class DecisionResult:
1213
decisions: list[Decision]
14+
force_create_new_decision_task: bool = False
15+
query_results: Optional[dict] = None
1316

1417
class WorkflowEngine:
15-
def __init__(self, info: WorkflowInfo, client: Client):
18+
def __init__(self, info: WorkflowInfo, client: Client, workflow_func: Optional[Callable[..., Any]] = None):
1619
self._context = Context(client, info)
20+
self._workflow_func = workflow_func
1721

1822
# TODO: Implement this
19-
def process_decision(self, decision_task: PollForDecisionTaskResponse) -> DecisionResult:
23+
async def process_decision(self, decision_task: PollForDecisionTaskResponse) -> DecisionResult:
2024
with self._context._activate():
2125
return DecisionResult(decisions=[])

cadence/worker/_base_task_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from abc import ABC, abstractmethod
3-
from typing import TypeVar, Generic
3+
from typing import Any, Dict, TypeVar, Generic
44

55
logger = logging.getLogger(__name__)
66

cadence/worker/_decision_task_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from typing import Dict, Any
2+
from typing import Dict
33

44
from cadence.api.v1.common_pb2 import Payload
55
from cadence.api.v1.service_worker_pb2 import (

tests/cadence/worker/test_base_task_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"""
55

66
import pytest
7-
from unittest.mock import Mock, AsyncMock, patch
8-
from typing import Any
7+
from unittest.mock import Mock
98

109
from cadence.worker._base_task_handler import BaseTaskHandler
1110

tests/cadence/worker/test_decision_task_handler.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55

66
import pytest
77
from unittest.mock import Mock, AsyncMock, patch, PropertyMock
8-
from typing import Dict, Any
98

109
from cadence.api.v1.common_pb2 import Payload
1110
from cadence.api.v1.service_worker_pb2 import (
1211
PollForDecisionTaskResponse,
13-
RespondDecisionTaskCompletedRequest,
14-
RespondDecisionTaskFailedRequest
12+
RespondDecisionTaskCompletedRequest
1513
)
1614
from cadence.api.v1.workflow_pb2 import DecisionTaskFailedCause
1715
from cadence.api.v1.decision_pb2 import Decision
1816
from cadence.client import Client
1917
from cadence.worker._decision_task_handler import DecisionTaskHandler
2018
from cadence.worker._registry import Registry
21-
from cadence.workflow import WorkflowInfo
2219
from cadence._internal.workflow.workflow_engine import WorkflowEngine, DecisionResult
2320

2421

@@ -268,8 +265,8 @@ async def test_respond_decision_task_completed_success(self, handler, sample_dec
268265
assert isinstance(call_args, RespondDecisionTaskCompletedRequest)
269266
assert call_args.task_token == sample_decision_task.task_token
270267
assert call_args.identity == handler._identity
271-
assert call_args.return_new_decision_task == True
272-
assert call_args.force_create_new_decision_task == True
268+
assert call_args.return_new_decision_task
269+
assert call_args.force_create_new_decision_task
273270
assert len(call_args.decisions) == 2
274271
# query_results should not be set when None
275272
assert not hasattr(call_args, 'query_results') or len(call_args.query_results) == 0
@@ -285,8 +282,8 @@ async def test_respond_decision_task_completed_no_query_results(self, handler, s
285282
await handler._respond_decision_task_completed(sample_decision_task, decision_result)
286283

287284
call_args = handler._client.worker_stub.RespondDecisionTaskCompleted.call_args[0][0]
288-
assert call_args.return_new_decision_task == False
289-
assert call_args.force_create_new_decision_task == False
285+
assert not call_args.return_new_decision_task
286+
assert not call_args.force_create_new_decision_task
290287
assert len(call_args.decisions) == 0
291288
# query_results should not be set when None
292289
assert not hasattr(call_args, 'query_results') or len(call_args.query_results) == 0

0 commit comments

Comments
 (0)