8 Commits

Author SHA1 Message Date
William Cheng
bd8cd8bf9f update python samples 2024-12-30 11:54:55 +08:00
Jonathan Ballet
22a0fc1727
python: adjust basic typing information (#17511)
* python: adjust basic typing information

This is an initial pass to fix and adjust the typing information for the
generated client. This is enough to have mypy runnning without complains
on all the (modern) generated clients (Pydantic v1 code is not checked
for instance)

mypy is also now run directly in the CI, so further changes will also be
checked and thus, will need to be compliant with good typing
information.

Note that this doesn't *fully* type all the code: mypy is not run in
"strict" mode and there are still many functions/methods/attributes
which are still not fully typed, but it's a first good step in that
direction.

* ApiResponse's raw_data can't be None

* Fix indentation

* Revert test changes

* run mypy on tests/ directory

* don't forcefully convert the client response headers to dict

* override petstore ApiResponse model

* adjust type of 'any/one_of_schemas' fields
2024-01-06 15:40:42 +08:00
Robert Schweizer
e47e7041f7
[python][Feat] Deserialize error responses (#17038)
* 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
2023-11-16 00:37:04 +08:00
ふぁ
8827da8012
[python] fix typing for API responses (#16802)
* [python] remove _preload_content

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove _return_http_data_only

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove async_req

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix typing for API responses

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix AttributeError

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove _preload_content

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix response_type

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix typo

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update simplify RESTClientObject

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update split call_api into 4 functions

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update improve stream

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove kwargs

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update ApiResponse

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] add method for each return value

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update test

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update docs

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] add constantParams

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix ImportError

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix SyntaxError in RESTResponse

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] add ApiResponse model_config

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix when isBinary is str

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update type

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] add rest with pydantic v1

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update format

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update format and type

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] add test

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update type to pydantic strict type

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove leftover files

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove descriptions per field

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] add test

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix test

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] fix test

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove multiprocessing

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] add blank line to docstring

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update docstring

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] remove unwanted imports in rest

Signed-off-by: ふぁ <yuki@yuki0311.com>

---------

Signed-off-by: ふぁ <yuki@yuki0311.com>
2023-10-30 12:37:23 +08:00
jessemyers-lettuce
40731ed52d
python: several typing and style improvements (#16378)
* 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
2023-09-02 01:03:02 +08:00
ふぁ
f3b930c48c
[python-nextgen] Fix noqa: E501 position (#16280)
* Fix `noqa: E501` position

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python-nextgen] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

---------

Signed-off-by: ふぁ <yuki@yuki0311.com>
2023-08-08 20:42:12 +08:00
gyoganathan
fc474eab5f
Added BadRequestException as a subclass in python (#15722)
Co-authored-by: Gomathi Yoganathan <gyoganathan@C02G45FPMD6R.corp.proofpoint.com>
2023-06-10 15:27:18 +08:00
William Cheng
01ed5975e1
rename python-nextgen to python (#15504) 2023-05-16 13:54:07 +08:00