Skip to content

Commit 408ccb1

Browse files
Bernd VerstCopilot
andcommitted
Align pre-existing context manager methods with repo idiom
Apply the same `__enter__`/`__exit__` typing pattern that PR #145 uses for `TaskHubGrpcClient` (and that `BlobPayloadStore` already follows) to three pre-existing context managers that were either untyped or shadowed a builtin: * `AsyncTaskHubGrpcClient.__aenter__` now returns the concrete type and `__aexit__` takes `*args: object` with `-> None`. * `TaskHubGrpcWorker.__enter__/__exit__` get the same treatment, also removing the `type` parameter that shadowed the builtin. * `EntityLock.__enter__/__exit__` get the same treatment; the file already has `from __future__ import annotations` so the return annotation is the bare class name. Behavior is unchanged: each `__exit__` still delegates to its existing teardown method (`close`/`stop`/`_exit_critical_section`), so the gRPC resiliency teardown added in PR #135 continues to flow through `TaskHubGrpcClient.close()` unchanged. No changelog entry: per the repo's contributor guidance, internal-only type-annotation refactors with no externally observable behavior change are excluded from the changelog. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4e45473 commit 408ccb1

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

durabletask/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,10 @@ async def close(self) -> None:
789789
await retired_channel.close()
790790
await self._channel.close()
791791

792-
async def __aenter__(self):
792+
async def __aenter__(self) -> "AsyncTaskHubGrpcClient":
793793
return self
794794

795-
async def __aexit__(self, exc_type, exc_val, exc_tb):
795+
async def __aexit__(self, *args: object) -> None:
796796
await self.close()
797797

798798
def _schedule_recreate(self) -> None:

durabletask/entities/entity_lock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class EntityLock:
1212
def __init__(self, context: OrchestrationContext):
1313
self._context = context
1414

15-
def __enter__(self):
15+
def __enter__(self) -> EntityLock:
1616
return self
1717

18-
def __exit__(self, exc_type, exc_val, exc_tb):
18+
def __exit__(self, *args: object) -> None:
1919
self._context._exit_critical_section()

durabletask/worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,10 @@ def maximum_timer_interval(self) -> timedelta | None:
581581
"""Get the configured maximum timer interval for long timer chunking."""
582582
return self._maximum_timer_interval
583583

584-
def __enter__(self):
584+
def __enter__(self) -> "TaskHubGrpcWorker":
585585
return self
586586

587-
def __exit__(self, type, value, traceback):
587+
def __exit__(self, *args: object) -> None:
588588
self.stop()
589589

590590
def _classify_stream_outcome(

0 commit comments

Comments
 (0)