feat(python): expose all config properties in constructor#23021
feat(python): expose all config properties in constructor#23021timonrieger wants to merge 5 commits intoOpenAPITools:masterfrom
Conversation
There was a problem hiding this comment.
5 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="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: Constructor still lacks newly documented parameters (retries, cert_file, proxy, etc.), so passing these advertised keyword arguments will raise TypeError.</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:58">
P2: Constructor docstring now advertises parameters (e.g., retries, cert_file, proxy) that are not accepted by __init__, so passing them will raise unexpected keyword argument errors.</violation>
</file>
<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:54">
P2: Docstring documents new constructor parameters (e.g., retries, cert_file, key_file, proxy, connection_pool_maxsize) but __init__ does not accept them, so using these documented arguments will raise `TypeError: __init__() got an unexpected keyword argument`.</violation>
</file>
<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: Constructor docstring documents new parameters (cert_file, retries, proxy, etc.) but __init__ does not accept them, so using documented kwargs will raise a TypeError and users cannot set these values via the constructor.</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:286">
P3: `assert_hostname` is typed as Optional[bool], but urllib3 accepts a string hostname (or False/None). This type hint incorrectly excludes valid string values, causing type-checkers to flag legitimate 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: Constructor still lacks newly documented parameters (retries, cert_file, proxy, etc.), so passing these advertised keyword arguments will raise TypeError.
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>Constructor still lacks newly documented parameters (retries, cert_file, proxy, etc.), so passing these advertised keyword arguments will raise TypeError.</comment>
<file context>
@@ -81,7 +96,7 @@ def __init__(self, host=None,
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,
) -> None:
"""Constructor
</file context>
samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/configuration.py
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache
Outdated
Show resolved
Hide resolved
| 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: Constructor docstring documents new parameters (cert_file, retries, proxy, etc.) but init does not accept them, so using documented kwargs will raise a TypeError and users cannot set these values via the constructor.
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>Constructor docstring documents new parameters (cert_file, retries, proxy, etc.) but __init__ does not accept them, so using documented kwargs will raise a TypeError and users cannot set these values via the constructor.</comment>
<file context>
@@ -141,7 +156,7 @@ def __init__(self, host=None,
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,
) -> None:
"""Constructor
</file context>
| cert_file: Optional[str]=None, | ||
| key_file: Optional[str]=None, | ||
| verify_ssl: bool=True, | ||
| assert_hostname: Optional[bool]=None, |
There was a problem hiding this comment.
P3: assert_hostname is typed as Optional[bool], but urllib3 accepts a string hostname (or False/None). This type hint incorrectly excludes valid string values, causing type-checkers to flag legitimate usage.
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/petstore_api/configuration.py, line 286:
<comment>`assert_hostname` is typed as Optional[bool], but urllib3 accepts a string hostname (or False/None). This type hint incorrectly excludes valid string values, causing type-checkers to flag legitimate usage.</comment>
<file context>
@@ -270,6 +282,17 @@ def __init__(
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,
+ connection_pool_maxsize: Optional[int]=None,
</file context>
| assert_hostname: Optional[bool]=None, | |
| assert_hostname: Optional[Union[bool, str]]=None, |
There was a problem hiding this comment.
1 issue 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: verify_ssl is no longer configurable in the constructor; it’s hardcoded to True, removing the ability to pass verify_ssl=False during initialization.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -602,4 +602,4 @@ def host(self): | |||
| def host(self, value): | |||
There was a problem hiding this comment.
P2: verify_ssl is no longer configurable in the constructor; it’s hardcoded to True, removing the ability to pass verify_ssl=False during initialization.
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 211:
<comment>verify_ssl is no longer configurable in the constructor; it’s hardcoded to True, removing the ability to pass verify_ssl=False during initialization.</comment>
<file context>
@@ -223,7 +208,7 @@ def __init__(self, host=None,
"""
- self.verify_ssl = verify_ssl
+ self.verify_ssl = True
"""SSL/TLS verification
Set this to false to skip verifying SSL certificate when calling API
</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 all Python client Configuration options as constructor parameters so users can set everything at initialization. Defaults are preserved; samples and docstrings updated, and pydantic v1 templates remain unchanged after reverting earlier additions.
Written for commit c4f0cc3. Summary will update on new commits.