feat(python): expose all config properties in constructor#23020
feat(python): expose all config properties in constructor#23020timonrieger wants to merge 4 commits intoOpenAPITools:masterfrom
Conversation
There was a problem hiding this comment.
6 issues found across 11 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache:262">
P2: Asyncio constructor treats `None` as “use default 100,” so callers cannot request the documented `None` = no‑limit behavior via the constructor.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py:394">
P2: Constructor now coerces connection_pool_maxsize=None to 100, so callers cannot use the documented “None means no-limit” behavior when configuring via the constructor.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/configuration.py">
<violation number="1" location="samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/configuration.py:253">
P2: Passing connection_pool_maxsize=None (documented as “no limit”) is coerced to 100, so the constructor cannot configure an unlimited pool as documented.</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/configuration.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/configuration.py:280">
P2: Adding `verify_ssl` as a positional parameter before existing arguments shifts positional mappings (e.g., `ssl_ca_cert` now binds to `verify_ssl`), breaking backward compatibility for callers using positional args. Consider appending new parameters at the end or making them keyword-only to avoid this break.</violation>
</file>
<file name="samples/client/echo_api/python/openapi_client/configuration.py">
<violation number="1" location="samples/client/echo_api/python/openapi_client/configuration.py:215">
P2: Adding new parameters before existing ones in `Configuration.__init__` changes positional argument ordering, which is a backward-incompatible API change. Any downstream code that passed `ssl_ca_cert`, `retries`, or related arguments positionally will now bind values to the wrong parameters (e.g., `ssl_ca_cert` now maps to `verify_ssl`).</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/python/configuration.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/python/configuration.mustache:314">
P2: Adding `verify_ssl` before existing positional parameters changes the constructor’s positional argument order, breaking callers that pass `ssl_ca_cert`/`retries`/etc. positionally and potentially misconfiguring SSL settings.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| {{#asyncio}} | ||
| self.connection_pool_maxsize = 100 | ||
| self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else 100 |
There was a problem hiding this comment.
P2: Asyncio constructor treats None as “use default 100,” so callers cannot request the documented None = no‑limit behavior via the constructor.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache, line 262:
<comment>Asyncio constructor treats `None` as “use default 100,” so callers cannot request the documented `None` = no‑limit behavior via the constructor.</comment>
<file context>
@@ -215,36 +236,36 @@ conf = {{{packageName}}}.Configuration(
{{#asyncio}}
- self.connection_pool_maxsize = 100
+ self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else 100
"""This value is passed to the aiohttp to limit simultaneous connections.
Default values is 100, None means no-limit.
</file context>
There was a problem hiding this comment.
4 issues found across 4 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py">
<violation number="1">
P2: Constructor no longer accepts documented config parameters (e.g., cert_file, retries, proxy) and now hardcodes defaults, preventing customization and causing TypeError for callers who pass those args.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/configuration.py">
<violation number="1">
P2: Constructor no longer accepts documented config options and now hard-codes their values, breaking callers that pass kwargs like cert_file/proxy/retries and preventing overrides.</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache">
<violation number="1">
P2: Constructor no longer accepts documented configuration parameters and hard-codes their defaults, so callers cannot pass options like retries/cert_file/proxy and the docstring is misleading.</violation>
</file>
<file name="samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py">
<violation number="1">
P2: Constructor no longer accepts documented configuration parameters and now hard-codes defaults, so passing documented kwargs (e.g., retries, proxy, formats) raises TypeError and prevents configuration at construction.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -52,8 +52,23 @@ class Configuration: | |||
| string values to replace variables in templated server configuration. | |||
There was a problem hiding this comment.
P2: Constructor no longer accepts documented config parameters (e.g., cert_file, retries, proxy) and now hardcodes defaults, preventing customization and causing TypeError for callers who pass those args.
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-pydantic-v1/petstore_api/configuration.py, line 234:
<comment>Constructor no longer accepts documented config parameters (e.g., cert_file, retries, proxy) and now hardcodes defaults, preventing customization and causing TypeError for callers who pass those args.</comment>
<file context>
@@ -237,52 +231,52 @@ def __init__(self, host=None,
"""Set this to customize the certificate file to verify the peer.
"""
- self.cert_file = cert_file
+ self.cert_file = None
"""client certificate file
"""
</file context>
| @@ -51,8 +51,23 @@ class Configuration: | |||
| string values to replace variables in templated server configuration. | |||
There was a problem hiding this comment.
P2: Constructor no longer accepts documented config options and now hard-codes their values, breaking callers that pass kwargs like cert_file/proxy/retries and preventing overrides.
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-pydantic-v1-aiohttp/petstore_api/configuration.py, line 233:
<comment>Constructor no longer accepts documented config options and now hard-codes their values, breaking callers that pass kwargs like cert_file/proxy/retries and preventing overrides.</comment>
<file context>
@@ -236,49 +230,49 @@ def __init__(self, host=None,
"""Set this to customize the certificate file to verify the peer.
"""
- self.cert_file = cert_file
+ self.cert_file = None
"""client certificate file
"""
</file context>
| @@ -47,8 +47,23 @@ class Configuration: | |||
| string values to replace variables in templated server configuration. | |||
There was a problem hiding this comment.
P2: Constructor no longer accepts documented configuration parameters and hard-codes their defaults, so callers cannot pass options like retries/cert_file/proxy and the docstring is misleading.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache, line 241:
<comment>Constructor no longer accepts documented configuration parameters and hard-codes their defaults, so callers cannot pass options like retries/cert_file/proxy and the docstring is misleading.</comment>
<file context>
@@ -244,28 +238,28 @@ conf = {{{packageName}}}.Configuration(
"""Set this to customize the certificate file to verify the peer.
"""
- self.cert_file = cert_file
+ self.cert_file = None
"""client certificate file
"""
</file context>
| @@ -51,8 +51,23 @@ class Configuration: | |||
| string values to replace variables in templated server configuration. | |||
There was a problem hiding this comment.
P2: Constructor no longer accepts documented configuration parameters and now hard-codes defaults, so passing documented kwargs (e.g., retries, proxy, formats) raises TypeError and prevents configuration at construction.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py, line 200:
<comment>Constructor no longer accepts documented configuration parameters and now hard-codes defaults, so passing documented kwargs (e.g., retries, proxy, formats) raises TypeError and prevents configuration at construction.</comment>
<file context>
@@ -172,52 +166,52 @@ def __init__(self, host=None,
"""Safe chars for path_param
"""
- self.retries = retries
+ self.retries = None
"""Adding retries to override urllib3 default value 3
"""
</file context>
There was a problem hiding this comment.
3 issues found across 11 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py">
<violation number="1" location="samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py:159">
P2: Reordering verify_ssl and ssl_ca_cert breaks positional callers; a boolean intended for verify_ssl will now bind to ssl_ca_cert, leaving verify_ssl at its default and potentially misconfiguring SSL verification.</violation>
</file>
<file name="samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py">
<violation number="1" location="samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py:99">
P2: Swapping `ssl_ca_cert` and `verify_ssl` in the constructor breaks positional-argument callers and can silently change SSL verification behavior (e.g., disabling verification no longer works). This is a backward-incompatible change to a public API.</violation>
</file>
<file name="samples/client/echo_api/python/openapi_client/configuration.py">
<violation number="1" location="samples/client/echo_api/python/openapi_client/configuration.py:220">
P2: Reordering verify_ssl in the constructor signature is a backward-incompatible change for positional callers; their boolean will now map to ssl_ca_cert and verify_ssl will fall back to True. Consider keeping the original argument order or making new parameters keyword-only to avoid breaking positional usage.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| server_index=None, server_variables=None, | ||
| server_operation_index=None, server_operation_variables=None, | ||
| ssl_ca_cert=None, | ||
| ssl_ca_cert=None, verify_ssl=True, |
There was a problem hiding this comment.
P2: Reordering verify_ssl and ssl_ca_cert breaks positional callers; a boolean intended for verify_ssl will now bind to ssl_ca_cert, leaving verify_ssl at its default and potentially misconfiguring SSL verification.
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-pydantic-v1/petstore_api/configuration.py, line 159:
<comment>Reordering verify_ssl and ssl_ca_cert breaks positional callers; a boolean intended for verify_ssl will now bind to ssl_ca_cert, leaving verify_ssl at its default and potentially misconfiguring SSL verification.</comment>
<file context>
@@ -156,7 +156,7 @@ def __init__(self, host=None,
server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
- verify_ssl=True, ssl_ca_cert=None,
+ ssl_ca_cert=None, verify_ssl=True,
) -> None:
"""Constructor
</file context>
| server_index=None, server_variables=None, | ||
| server_operation_index=None, server_operation_variables=None, | ||
| ssl_ca_cert=None, | ||
| ssl_ca_cert=None, verify_ssl=True, |
There was a problem hiding this comment.
P2: Swapping ssl_ca_cert and verify_ssl in the constructor breaks positional-argument callers and can silently change SSL verification behavior (e.g., disabling verification no longer works). This is a backward-incompatible change to a public API.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py, line 99:
<comment>Swapping `ssl_ca_cert` and `verify_ssl` in the constructor breaks positional-argument callers and can silently change SSL verification behavior (e.g., disabling verification no longer works). This is a backward-incompatible change to a public API.</comment>
<file context>
@@ -96,7 +96,7 @@ def __init__(self, host=None,
server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
- verify_ssl=True, ssl_ca_cert=None,
+ ssl_ca_cert=None, verify_ssl=True,
) -> None:
"""Constructor
</file context>
| ca_cert_data: Optional[Union[str, bytes]] = None, | ||
| cert_file: Optional[str]=None, | ||
| key_file: Optional[str]=None, | ||
| verify_ssl: bool=True, |
There was a problem hiding this comment.
P2: Reordering verify_ssl in the constructor signature is a backward-incompatible change for positional callers; their boolean will now map to ssl_ca_cert and verify_ssl will fall back to True. Consider keeping the original argument order or making new parameters keyword-only to avoid breaking positional usage.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/echo_api/python/openapi_client/configuration.py, line 220:
<comment>Reordering verify_ssl in the constructor signature is a backward-incompatible change for positional callers; their boolean will now map to ssl_ca_cert and verify_ssl will fall back to True. Consider keeping the original argument order or making new parameters keyword-only to avoid breaking positional usage.</comment>
<file context>
@@ -212,12 +212,12 @@ def __init__(
ca_cert_data: Optional[Union[str, bytes]] = None,
cert_file: Optional[str]=None,
key_file: Optional[str]=None,
+ verify_ssl: bool=True,
assert_hostname: Optional[bool]=None,
tls_server_name: Optional[str]=None,
</file context>
Configuration options that were only assignable after construction are now constructor parameters for the Python generator, so callers can set them in one place.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)
Summary by cubic
Expose more Configuration options as constructor args for the Python generator, and add verify_ssl to Python-Pydantic-V1. This lets callers set SSL, retries, proxies, pool size, and serialization at construction, with verify_ssl and pool size defaults applied correctly.
Written for commit bb0ead0. Summary will update on new commits.