in azure/durable_functions/decorators/durable_app.py [0:0]
def _add_rich_client(self, fb, parameter_name,
client_constructor):
# Obtain user-code and force type annotation on the client-binding parameter to be `str`.
# This ensures a passing type-check of that specific parameter,
# circumventing a limitation of the worker in type-checking rich DF Client objects.
# TODO: Once rich-binding type checking is possible, remove the annotation change.
user_code = fb._function._func
user_code.__annotations__[parameter_name] = str
# `wraps` This ensures we re-export the same method-signature as the decorated method
@wraps(user_code)
async def df_client_middleware(*args, **kwargs):
# Obtain JSON-string currently passed as DF Client,
# construct rich object from it,
# and assign parameter to that rich object
starter = kwargs[parameter_name]
client = client_constructor(starter)
kwargs[parameter_name] = client
# Invoke user code with rich DF Client binding
return await user_code(*args, **kwargs)
user_code_with_rich_client = df_client_middleware
fb._function._func = user_code_with_rich_client