Skip to content

Conversation

@aditya-arolkar-swe
Copy link
Contributor

@aditya-arolkar-swe aditya-arolkar-swe commented Nov 5, 2025

Description

Closes FER-6558

Integrates x-fern-retries extension into the generated Python SDK.

I.e. specify in your OpenAPI spec:

paths:
  /imdb/movies/:
    get:
      x-fern-retries:
        disabled: true
        ...

and the generated raw_client.py will enforce no retries:

class RawClient:
    ...

    def get_movie(
        ...
    ) -> HttpResponse[Movie]:
        _request_options_with_retries_disabled = (
            # even if end-user specifies max_retries, will override to 0
            {**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
        )
        _response = self._client_wrapper.httpx_client.request(
            ...
            json={
                ...
                request_options=_request_options_with_retries_disabled,
                ...
            }
            ...
        )

Changes Made

  • updated endpoint_function_generator.py to pass in specified request_options
  • kept http_client.py implementation the same

Testing

  • Unit tests added/updated
  • Manual testing completed

@fern-support fern-support changed the title feat(python): hard-set retries disabled config at level feat(python): hard-set retries disabled config at raw_client.py level Nov 5, 2025
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:
Copy link
Collaborator

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}} ')
Copy link
Collaborator

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

Copy link
Collaborator

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}

Copy link
Contributor Author

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

@aditya-arolkar-swe aditya-arolkar-swe merged commit 5e8d1e3 into main Nov 6, 2025
260 checks passed
@aditya-arolkar-swe aditya-arolkar-swe deleted the aa/python-sdk-integrate-retries-config branch November 6, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants