Skip to content

Commit 8c5a626

Browse files
committed
Preserve supported client annotations
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 76f2163a-0773-4889-b627-1bd4e5c7bea0
1 parent 524ddb2 commit 8c5a626

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

azure-functions-durable/azure/durable_functions/decorators/durable_app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,14 @@ def bind_client(
428428

429429
def set_client_metadata(client_bound: Callable[..., Any]) -> None:
430430
annotations = dict(function.__annotations__)
431-
annotations.setdefault(client_name, str)
431+
supported_client_types = (
432+
str,
433+
bytes,
434+
DurableFunctionsClient,
435+
SyncDurableFunctionsClient,
436+
)
437+
if annotations.get(client_name) not in supported_client_types:
438+
annotations[client_name] = str
432439
client_bound.__annotations__ = annotations
433440
setattr(client_bound, "client_function", function)
434441

tests/azure-functions-durable/test_decorator_compat.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@ async def starter(client: df.DurableFunctionsClient):
172172
assert await fb._function._func(client="{}") == "DurableFunctionsClient"
173173

174174

175+
async def test_durable_client_input_replaces_unsupported_client_annotation():
176+
app = df.DFApp()
177+
178+
async def starter(client: int):
179+
return type(client).__name__
180+
181+
fb = app.durable_client_input(client_name="client")(starter)
182+
assert fb._function._func.__annotations__["client"] is str
183+
assert starter.__annotations__["client"] is int
184+
185+
175186
# ---------------------------------------------------------------------------
176187
# All decorators register a function builder
177188
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)