Skip to content

Commit dc1e9e0

Browse files
committed
fix: fmt and tests
1 parent 9bee258 commit dc1e9e0

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

upstash_workflow/asyncio/serve/serve.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ def _serve_base(
7070

7171
async def _handler(request: TRequest) -> TResponse:
7272
workflow_url, workflow_failure_url = _determine_urls(
73-
cast(_AsyncRequest, request), url, base_url, failure_function, failure_url
73+
cast(_AsyncRequest, request),
74+
url,
75+
base_url,
76+
False if failure_function is None else True,
77+
failure_url,
7478
)
7579

7680
request_payload = await _get_payload(request) or ""

upstash_workflow/asyncio/workflow_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ async def _handle_failure(
8484

8585
# Attempt running route_function until the first step
8686
auth_check = await _DisabledWorkflowContext[Any].try_authentication(
87-
route_function, cast(AsyncWorkflowContext[TInitialPayload], workflow_context)
87+
route_function,
88+
cast(AsyncWorkflowContext[TInitialPayload], workflow_context),
8889
)
8990

9091
if auth_check == "run-ended":

upstash_workflow/context/auto_executor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def submit_steps_to_qstash(
7777
self.context.retries,
7878
lazy_step.retries if isinstance(lazy_step, _LazyCallStep) else None,
7979
lazy_step.timeout if isinstance(lazy_step, _LazyCallStep) else None,
80+
workflow_failure_url=self.context.failure_url,
8081
).headers
8182

8283
will_wait = (

upstash_workflow/serve/options.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
_FinishCondition,
2222
)
2323
from upstash_workflow import WorkflowContext
24-
from upstash_workflow import AsyncWorkflowContext
2524
from dataclasses import dataclass
2625

2726
_logger = logging.getLogger(__name__)
@@ -156,12 +155,7 @@ def _determine_urls(
156155
request: Union[_SyncRequest, _AsyncRequest],
157156
url: Optional[str],
158157
base_url: Optional[str],
159-
failure_function: Optional[
160-
Callable[
161-
[Union[WorkflowContext[TInitialPayload], AsyncWorkflowContext[TInitialPayload]], int, str, Dict[str, str]],
162-
Any,
163-
]
164-
],
158+
failure_function_exists: bool,
165159
failure_url: Optional[str],
166160
) -> Tuple[str, str | None]:
167161
initial_workflow_url = str(url if url is not None else request.url)
@@ -178,7 +172,7 @@ def replace_base(match: Match[str]) -> str:
178172
else:
179173
workflow_url = initial_workflow_url
180174

181-
workflow_failure_url = workflow_url if failure_function else failure_url
175+
workflow_failure_url = workflow_url if failure_function_exists else failure_url
182176
return cast(Tuple[str, str | None], [workflow_url, workflow_failure_url])
183177

184178

upstash_workflow/serve/serve.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ def _handler(request: TRequest) -> TResponse:
8080
:return: A response.
8181
"""
8282
workflow_url, workflow_failure_url = _determine_urls(
83-
cast(_SyncRequest, request), url, base_url, failure_function, failure_url
83+
cast(_SyncRequest, request),
84+
url,
85+
base_url,
86+
False if failure_function is None else True,
87+
failure_url,
8488
)
8589

8690
request_payload = _get_payload(request) or ""

upstash_workflow/workflow_parser.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import json
2-
from typing import Optional, List, Tuple, Union, Callable, Dict, Any, Literal, TypeVar, cast
2+
from typing import (
3+
Optional,
4+
List,
5+
Tuple,
6+
Union,
7+
Callable,
8+
Dict,
9+
Any,
10+
Literal,
11+
TypeVar,
12+
cast,
13+
)
314
from upstash_workflow.utils import _nanoid, _decode_base64
415
from upstash_workflow.constants import (
516
WORKFLOW_PROTOCOL_VERSION,

0 commit comments

Comments
 (0)