Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,20 @@ class RESTClientObject:
self.proxy = configuration.proxy
self.proxy_headers = configuration.proxy_headers

self.retries = configuration.retries
retries = configuration.retries
if retries is None:
self._effective_retry_options = None
elif isinstance(retries, aiohttp_retry.RetryOptionsBase):
self._effective_retry_options = retries
elif isinstance(retries, int):
self._effective_retry_options = aiohttp_retry.ExponentialRetry(
attempts=retries,
factor=2.0,
start_timeout=0.1,
max_timeout=120.0
)
else:
self._effective_retry_options = None

self.pool_manager: Optional[aiohttp.ClientSession] = None
self.retry_client: Optional[aiohttp_retry.RetryClient] = None
Expand Down Expand Up @@ -191,16 +204,11 @@ class RESTClientObject:
)
pool_manager = self.pool_manager

if self.retries is not None and method in ALLOW_RETRY_METHODS:
if self._effective_retry_options is not None and method in ALLOW_RETRY_METHODS:
if self.retry_client is None:
self.retry_client = aiohttp_retry.RetryClient(
client_session=self.pool_manager,
retry_options=aiohttp_retry.ExponentialRetry(
attempts=self.retries,
factor=2.0,
start_timeout=0.1,
max_timeout=120.0
)
retry_options=self._effective_retry_options
)
pool_manager = self.retry_client

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ class Configuration:
values before.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
{{#async}}
:param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration.
{{/async}}
{{^async}}
:param retries: int | urllib3.util.retry.Retry - Retry configuration.
{{/async}}
:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
Expand Down Expand Up @@ -298,7 +303,7 @@ conf = {{{packageName}}}.Configuration(
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
retries: Optional[Union[int, Any]] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
Expand Down Expand Up @@ -432,7 +437,7 @@ conf = {{{packageName}}}.Configuration(
"""Safe chars for path_param
"""
self.retries = retries
"""Adding retries to override urllib3 default value 3
"""Retry configuration
"""
# Enable client side validation
self.client_side_validation = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Configuration:
values before.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
:param retries: int | urllib3.util.retry.Retry - Retry configuration.
:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
Expand Down Expand Up @@ -203,7 +203,7 @@ def __init__(
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
retries: Optional[Union[int, Any]] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
Expand Down Expand Up @@ -320,7 +320,7 @@ def __init__(
"""Safe chars for path_param
"""
self.retries = retries
"""Adding retries to override urllib3 default value 3
"""Retry configuration
"""
# Enable client side validation
self.client_side_validation = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Configuration:
values before.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
:param retries: int | urllib3.util.retry.Retry - Retry configuration.
:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
Expand Down Expand Up @@ -203,7 +203,7 @@ def __init__(
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
retries: Optional[Union[int, Any]] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
Expand Down Expand Up @@ -320,7 +320,7 @@ def __init__(
"""Safe chars for path_param
"""
self.retries = retries
"""Adding retries to override urllib3 default value 3
"""Retry configuration
"""
# Enable client side validation
self.client_side_validation = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Configuration:
values before.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
:param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration.
:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
Expand Down Expand Up @@ -267,7 +267,7 @@ def __init__(
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
retries: Optional[Union[int, Any]] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
Expand Down Expand Up @@ -385,7 +385,7 @@ def __init__(
"""Safe chars for path_param
"""
self.retries = retries
"""Adding retries to override urllib3 default value 3
"""Retry configuration
"""
# Enable client side validation
self.client_side_validation = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,20 @@ def __init__(self, configuration) -> None:
self.proxy = configuration.proxy
self.proxy_headers = configuration.proxy_headers

self.retries = configuration.retries
retries = configuration.retries
if retries is None:
self._effective_retry_options = None
elif isinstance(retries, aiohttp_retry.RetryOptionsBase):
self._effective_retry_options = retries
elif isinstance(retries, int):
self._effective_retry_options = aiohttp_retry.ExponentialRetry(
attempts=retries,
factor=2.0,
start_timeout=0.1,
max_timeout=120.0
)
else:
self._effective_retry_options = None

self.pool_manager: Optional[aiohttp.ClientSession] = None
self.retry_client: Optional[aiohttp_retry.RetryClient] = None
Expand Down Expand Up @@ -200,16 +213,11 @@ async def request(
)
pool_manager = self.pool_manager

if self.retries is not None and method in ALLOW_RETRY_METHODS:
if self._effective_retry_options is not None and method in ALLOW_RETRY_METHODS:
if self.retry_client is None:
self.retry_client = aiohttp_retry.RetryClient(
client_session=self.pool_manager,
retry_options=aiohttp_retry.ExponentialRetry(
attempts=self.retries,
factor=2.0,
start_timeout=0.1,
max_timeout=120.0
)
retry_options=self._effective_retry_options
)
pool_manager = self.retry_client

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Configuration:
values before.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
:param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Docstring for retries references aiohttp_retry types in a python-httpx client, which is misleading and inconsistent with this sample’s HTTP library.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py, line 170:

<comment>Docstring for retries references aiohttp_retry types in a python-httpx client, which is misleading and inconsistent with this sample’s HTTP library.</comment>

<file context>
@@ -167,9 +167,7 @@ class Configuration:
-    :param retries: Retry config; type depends on library:
-        * urllib3: int | urllib3.util.retry.Retry
-        * asyncio: int | aiohttp_retry.RetryOptionsBase
+    :param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration.
     :param ca_cert_data: verify the peer using concatenated CA certificate data
       in PEM (str) or DER (bytes) format.
</file context>
Fix with Cubic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since class based retries are only supported by the urllib3 and asyncio generators, but not httpx, tornado, etc. this might be misleading, as setting the class on retries has no effect on those. However before this PR the retries config option had no effect on those generators anyways

:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
Expand Down Expand Up @@ -267,7 +267,7 @@ def __init__(
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
retries: Optional[Union[int, Any]] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
Expand Down Expand Up @@ -385,7 +385,7 @@ def __init__(
"""Safe chars for path_param
"""
self.retries = retries
"""Adding retries to override urllib3 default value 3
"""Retry configuration
"""
# Enable client side validation
self.client_side_validation = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class Configuration:
values before.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
:param retries: int | urllib3.util.retry.Retry - Retry configuration.
:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
Expand Down Expand Up @@ -268,7 +268,7 @@ def __init__(
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
retries: Optional[Union[int, Any]] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
Expand Down Expand Up @@ -390,7 +390,7 @@ def __init__(
"""Safe chars for path_param
"""
self.retries = retries
"""Adding retries to override urllib3 default value 3
"""Retry configuration
"""
# Enable client side validation
self.client_side_validation = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class Configuration:
values before.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
:param retries: int | urllib3.util.retry.Retry - Retry configuration.
:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
Expand Down Expand Up @@ -268,7 +268,7 @@ def __init__(
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
retries: Optional[Union[int, Any]] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
Expand Down Expand Up @@ -390,7 +390,7 @@ def __init__(
"""Safe chars for path_param
"""
self.retries = retries
"""Adding retries to override urllib3 default value 3
"""Retry configuration
"""
# Enable client side validation
self.client_side_validation = True
Expand Down
Loading