python: fix typing for API responses#16694
python: fix typing for API responses#16694multani wants to merge 1 commit intoOpenAPITools:masterfrom
Conversation
|
How do I get response headers? |
Ah yes, I'll change the type to an Union 👍 |
|
typing supports generics type |
|
The current |
Do you have any specific ideas in mind already? |
No. |
|
The goal of this PR is to have correct type annotations for the case that I think outside users are not supposed to set this flag, but rather use the plain client methods (not the A nicer solution could be to remove the |
|
Thanks @fa0311 and @robertschweizer for the suggestions, I'll take a look at how to proceed. From my understood, it would be better to:
This could also simplify the
This may require larger changes in |
The `*_with_http_info` methods, instead of returning a generic ApiResponse object now return the actual object the method relates to.
|
So, I made good progress on this, but this is also getting more complicated. I created an issue to discuss about these changes, outside of this pull request: #16788 I will push my last changes in this pull request: it has most of what I discuss in #16788 except the new There are still several mypy issues, but I think they are simpler to tackle after that:
I haven't checked the rest yet. |
The
*_with_http_infomethods, instead of returning a generic ApiResponse object now return the actual object the method relates to.The type returned is the same as the methods that call the
*_with_http_infomethods.The documentation also reflects the correct type.
To simplify the template generation, the return type information is generated in the Java generator code.
@wing328
@krjakbrjak
@fa0311
PR checklist
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*.For Windows users, please run the script in Git BASH.
master(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)