Skip to content

Commit f635076

Browse files
committed
fixes after merge, lint
Signed-off-by: Filinto Duran <[email protected]>
1 parent fcb6e0a commit f635076

File tree

14 files changed

+65
-44
lines changed

14 files changed

+65
-44
lines changed

durabletask/aio/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
WhenAnyResultAwaitable,
2222
gather,
2323
)
24+
from .client import AsyncTaskHubGrpcClient
2425

2526
# Compatibility protocol (core functionality only)
2627
from .compatibility import OrchestrationContextProtocol, ensure_compatibility
@@ -46,8 +47,6 @@
4647
sandbox_strict,
4748
)
4849

49-
from .client import AsyncTaskHubGrpcClient
50-
5150
__all__ = [
5251
"AsyncTaskHubGrpcClient",
5352
# Core classes

durabletask/aio/awaitables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def __repr__(self) -> str: # pragma: no cover
431431
return _CompletedProxy(self._tasks_like[0], completed)
432432

433433
# Map completed task back to the original item and return proxy
434-
for original, under in zip(self._tasks_like, underlying):
434+
for original, under in zip(self._tasks_like, underlying, strict=False):
435435
if completed == under:
436436
return _CompletedProxy(original, completed)
437437

durabletask/aio/sandbox.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
from .errors import NonDeterminismWarning, SandboxViolationError
2828

29+
# Capture environment variable at module load to avoid triggering non-determinism detection
30+
_DISABLE_DETECTION = os.getenv("DAPR_WF_DISABLE_DETECTION") == "true"
31+
2932

3033
class SandboxMode(str, Enum):
3134
"""Sandbox mode options.
@@ -295,8 +298,8 @@ def __enter__(self) -> "_Sandbox":
295298

296299
# Expose originals/mode to the async workflow context for controlled unsafe access
297300
try:
298-
setattr(self.async_ctx, "_sandbox_originals", dict(self.originals))
299-
setattr(self.async_ctx, "_sandbox_mode", self.mode)
301+
self.async_ctx._sandbox_originals = dict(self.originals)
302+
self.async_ctx._sandbox_mode = self.mode
300303
except Exception:
301304
# Context may not support attribute assignment; ignore
302305
pass
@@ -398,7 +401,7 @@ def __await__(self) -> Any:
398401
now_dt = None
399402
if now_dt is None:
400403
if hasattr(self.async_ctx, "current_utc_datetime"):
401-
now_dt = getattr(self.async_ctx, "current_utc_datetime")
404+
now_dt = self.async_ctx.current_utc_datetime
402405
else:
403406
base = getattr(self.async_ctx, "_base_ctx", None)
404407
now_dt = getattr(base, "current_utc_datetime", None) if base is not None else None
@@ -407,7 +410,7 @@ def __await__(self) -> Any:
407410
rng = deterministic_random(iid or "", now_dt)
408411
# Mark as deterministic so the detector can whitelist bound method calls
409412
try:
410-
setattr(rng, "_dt_deterministic", True)
413+
rng._dt_deterministic = True
411414
except Exception:
412415
pass
413416

@@ -581,10 +584,10 @@ async def _run_mixed() -> list[Any]:
581584
else:
582585
wf_group = wf_items
583586
wf_results: list[Any] = await WhenAllAwaitable(wf_group) # type: ignore[assignment]
584-
for pos, val in zip(wf_indices, wf_results):
587+
for pos, val in zip(wf_indices, wf_results, strict=False):
585588
merged[pos] = val
586589
# Then process native sequentially, honoring return_exceptions
587-
for pos, it in zip(native_indices, native_items):
590+
for pos, it in zip(native_indices, native_items, strict=False):
588591
try:
589592
merged[pos] = await it
590593
except Exception as e: # noqa: BLE001
@@ -737,8 +740,8 @@ def sandbox_scope(async_ctx: Any, mode: Union[str, SandboxMode]) -> Any:
737740
if mode_str not in valid_modes:
738741
raise ValueError(f"Invalid sandbox mode '{mode_str}'. Must be one of {valid_modes}")
739742

740-
# Check for global disable
741-
if mode_str != "off" and os.getenv("DAPR_WF_DISABLE_DETECTION") == "true":
743+
# Check for global disable (captured at module load to avoid non-determinism detection)
744+
if mode_str != "off" and _DISABLE_DETECTION:
742745
mode_str = "off"
743746

744747
with _Sandbox(async_ctx, mode_str):

durabletask/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def raise_if_failed(self):
5757
self.failure_details,
5858
)
5959

60-
6160
def to_json(self) -> Any:
6261
"""Parse serialized_output as JSON and return the resulting object.
6362

durabletask/deterministic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def random(self) -> random.Random:
9292
)
9393
# Mark as deterministic for sandbox detector whitelisting of bound methods
9494
try:
95-
setattr(rnd, "_dt_deterministic", True)
95+
rnd._dt_deterministic = True
9696
except Exception:
9797
pass
9898
return rnd

durabletask/internal/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
import os
88
from types import SimpleNamespace
9-
from typing import Any, Dict, Iterable, Optional, Sequence, Union
9+
from typing import Any, Optional, Sequence, Union
1010

1111
import grpc
1212

durabletask/task.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ def get_completed_tasks(self) -> int:
382382

383383

384384
class CompletableTask(Task[T]):
385-
def __init__(self):
386385
def __init__(self) -> None:
387386
super().__init__()
388387
self._retryable_parent: Optional["RetryableTask[Any]"] = None

durabletask/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from datetime import datetime, timedelta
1111
from threading import Event, Thread
1212
from types import GeneratorType
13-
from typing import Any, Callable, Dict, Generator, Optional, Sequence, TypeVar, Union
13+
from typing import Any, Callable, Generator, Optional, Sequence, TypeVar, Union
1414

1515
import grpc
1616
from google.protobuf import empty_pb2

tests/aio/test_e2e.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _log_orchestration_progress(
3737
try:
3838
st = hub_client.get_orchestration_state(instance_id, fetch_payloads=True)
3939
if st is None:
40-
print(f"[async e2e] state: None")
40+
print("[async e2e] state: None")
4141
else:
4242
status_name = st.runtime_status.name
4343
if status_name != last_status:
@@ -336,7 +336,7 @@ async def when_any_event_or_timeout(ctx: AsyncWorkflowContext, event_name: str)
336336
val = winner.get_result()
337337
print(f"[E2E] when_any_event_or_timeout winner=event val={val}")
338338
return {"winner": "event", "val": val}
339-
print(f"[E2E] when_any_event_or_timeout winner=timeout")
339+
print("[E2E] when_any_event_or_timeout winner=timeout")
340340
return {"winner": "timeout"}
341341

342342
cls.when_any_event_or_timeout = when_any_event_or_timeout

tests/aio/test_gather_behavior.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ def test_gather_return_exceptions_wraps_children() -> None:
8181
# The underlying tasks_like should be SwallowExceptionAwaitable instances
8282
assert isinstance(wa, WhenAllAwaitable)
8383
# Access internal for type check
84-
wrapped: List[Any] = getattr(wa, "_tasks_like") # type: ignore[attr-defined]
84+
wrapped: List[Any] = wa._tasks_like # type: ignore[attr-defined]
8585
assert all(isinstance(w, SwallowExceptionAwaitable) for w in wrapped)

0 commit comments

Comments
 (0)