This was removed in #16802, but using a higher value than 1,
or at least making this configurable makes complete sense.
Without this, we get a lot of these log messages:
[ WARNING] Connection pool is full, discarding connection:
* refactor: Clean up _response_types_map formatting
It matches black's behavior of having trailing commas now.
* test: Add test to reproduce #16967
* fix: deserialize responses even if no returnType
Closes#16967
* refactor: Simplify ApiException subclasses
* refactor: Move exception subtype choice to ApiException
* feat: Deserialize error responses and add to exceptions
* test: Add for error responses with model
For model classes with model_something fields, pydantic raises a warning by default:
`Field "model_something" has conflict with protected namespace "model_".`.
These warnings make no sense here, because most users of the generator have established APIs
that they cannot change to conform to pydantic's safety rules.
Pydantic will raise an error if we ever conflict with a current attribute like `model_dump`.
* chore: add test to show python bool url params are not lower case
* fix: python parameters_to_url_query template to properly detect booleans
* fix: typo in test
* fix: typo in test
* chore: update test name to snake case and be more descriptive
* refactor: Use newlines in _with_http_info call
This prevents too-long lines and matches the style that
black would enforce.
* fix: Do not pydantic-validate function args twice
Closes#15757
* python: type generated client using Self
This doesn't offer a clear win but this helps for:
* Using modern types and making the typing intent clearer
* Decreasing the need for `from __future__ import annotations`, since a
class can now refer to itself without using its name
* Using more `cls` to automatically refer to the class, instead of
respecifying the class name every time
Self is available from Python 3.11 and is provided in typing_extensions
(since 4.0.0) as a fallback for older versions
See: https://peps.python.org/pep-0673/
See: https://github.com/python/typing_extensions/blob/main/CHANGELOG.md#added-in-version-400
* generate code
The aenum dependency didn't provide any specific improvements over the
stdlib's enum module.
aenum also doesn't provide typing information at the moment.
This removes one dependency and will help for completing the typing of
the generated client.
* In samples/openapi3/client/petstore/python, this reduces the mypy errors from 435 to 178 errors
* In samples/openapi3/client/petstore/python-aiohttp, this reduces the mypy errors from 381 to 124 errors
* In samples/client/echo_api/python, this reduces the mypy errors from 131 to 25 errors
* add float as reserved world
* clean up
* update samples
* Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java
Co-authored-by: Jonathan Ballet <jon@multani.info>
* update doc
* uncomment test
---------
Co-authored-by: Jonathan Ballet <jon@multani.info>
* [python] fix TypeError
Signed-off-by: ふぁ <yuki@yuki0311.com>
* [python] update Private model attributes to Class vars
Signed-off-by: ふぁ <yuki@yuki0311.com>
* [python] rename the List of test cases to ListClass
Signed-off-by: ふぁ <yuki@yuki0311.com>
* [python] update samples
Signed-off-by: ふぁ <yuki@yuki0311.com>
* [python] rename the List of v1 test cases to ListClass
Signed-off-by: ふぁ <yuki@yuki0311.com>
* [python] rename the List of v1-aiohttp test cases to ListClass
Signed-off-by: ふぁ <yuki@yuki0311.com>
* update samples
---------
Signed-off-by: ふぁ <yuki@yuki0311.com>
Co-authored-by: William Cheng <wing328hk@gmail.com>
* python: improve type generation with more specific typing
* Annotate function parameters
* Remove unused imports
* remove unused files
* remove temporary hack
* remove lock file
* fix Annotated import
* support Python 3.7
* Regenerate code with typing-extensions
* Fix setup.py
* More Pydantic v2 compatibility
* depend on pydantic v2
* fix client_echo tests
* fix JSON serialization
* Fix references
* Skip circular dependency tests for now
* Temporarily hide the "float" property
The "float" property aliases the "float" type and completely breaks the
model: all the properties that were "float" now become the type of the
"float" property instead.
* Fix errors
* Import Literal from typing_extensions
* Fix GitHub Action workflows
* Fix Python 3.7 failure
* Fix quotes
* Apply suggestions from code review
* Fix tests
* split model imports from other modules imports
* fix workflow
* Comment the array unique items convertion, remove set translation
* Replace alias usage
* python: remove non-async code path from the aiohttp generator
This removes all the non-async code from the aiohttp generator:
* all the methods that should be asynchronous are marked as `async`
* the `async_req` parameter is gone; calls are directly awaitables now
* the async calls into a thread pool are gone and the thread pool is
gone too (now useless)
Closes: #15824Closes: #5539
Related: #763
Related: #3696
* Fix empty line
* remove more
Descriptions can easily exceed line-length limits because they are often
extracted from doc/comments strings, which may use unexpected formatting.
Python doc strings, in particular, are likely to use newlines, which mustache
does not preserve, causing descriptions to be condensed to a single line.
* python: several typing and style improvements
The generated (python) code fails with several standard validation tools,
including `flake8`, `mypy`, and `autoflake`. While fixing every possible
violation -- especially wrto typing -- woudl be a project, some of the
changes are fairly easy.
- The `autoflake` tool picks up on unused imports. These can just be removed.
- The `mypy` tool picks up on numerious typing violations, especially if set
to its strictest mode. As a starting point, all functions ought to annotate
a return type, including constructors, even if the return type is `None`
because otherwise the functions are omitted from type checking and it's
impossible to make incremental progress towards adding types.
- The `flake8` tool mostly finds whitespace and line-length issues; while
line-length standards very, the source already includes several flake8
ignores, so it seems safe to add a few more.
* Add generated files
* Restore imports used by `AbstractPythonCodegen.java`
* Update generated files
* bug: python client generator didn't respect range response specification (e.g. "1XX", "2XX", etx.). Return values tended to become None as a result
* update samples
---------
Co-authored-by: William Cheng <wing328hk@gmail.com>