-
Notifications
You must be signed in to change notification settings - Fork 267
feat(python): hard-set retries disabled config at raw_client.py level
#10367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python): hard-set retries disabled config at raw_client.py level
#10367
Conversation
…n-sdk-integrate-retries-config
raw_client.py level
| request_options_variable_name = last_param.name | ||
|
|
||
| # If retries are disabled, enforce max_retries=0 by overriding request_options | ||
| if endpoint.retries is not None and hasattr(endpoint.retries, "disabled") and endpoint.retries.disabled: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the type narrowing work for hasattr(endpoint.retries, "disabled") ? I tend to prefer an isinstance check so that type checking works better afterwards. Would be more relevant if we were doing more interesting stuff than just the boolean disabled
| overridden_request_options_var = "_request_options_with_retries_disabled" | ||
|
|
||
| def write_override_logic(writer: AST.NodeWriter) -> None: | ||
| writer.write(f'({{**{request_options_variable_name}, "max_retries": 0}} ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow the kwargs over a dict union, interesting choice 😅
jk I'm not sure which is more idiomatic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like (request_options_variable_name or {}) | {"max_retries": 0}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spoke offline: keeping current change for easier readability
…n-sdk-integrate-retries-config
Description
Closes FER-6558
Integrates
x-fern-retriesextension into the generated Python SDK.I.e. specify in your OpenAPI spec:
and the generated
raw_client.pywill enforce no retries:Changes Made
endpoint_function_generator.pyto pass in specified request_optionshttp_client.pyimplementation the sameTesting