Skip to content

Commit

Permalink
🐛 Remove Awaitable from return types in generated clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalkrupinski committed Jul 2, 2024
1 parent 7226cbd commit c74e054
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{{- render_param(param) }}
{%- endfor %}
) -> typing.Annotated[
Awaitable[{{ th.type_hint(func.response_body_type, path) }}],
{{ th.type_hint(func.response_body_type, path) }},
Responses({
{%- for code, mime_map in func.responses.items() %}
'{{ code }}': {{ render_mime_map(mime_map) | indent(12, False) }},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ __all__ = [
'ApiClient',
]

from collections.abc import Awaitable

import typing_extensions as typing
from lapidary.runtime import *

Expand Down
10 changes: 4 additions & 6 deletions tests/e2e/expected/dummy/gen/test_dummy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
'ApiClient',
]

from collections.abc import Awaitable

import typing_extensions as typing
from lapidary.runtime import *

Expand Down Expand Up @@ -46,7 +44,7 @@ async def test_op(
param1_q: typing.Annotated[test_dummy.components.schemas.schema1.schema.schema1, Query('param1', )],
param2_q: typing.Annotated[typing.Union[None, test_dummy.paths.u_ltestu_l.get.parameters.u_n.schema.schema.schema], Query('param2', )] = None,
) -> typing.Annotated[
Awaitable[typing.Union[test_dummy.components.responses.default.response.Response, test_dummy.paths.u_ltestu_l.get.responses.default.response.Response]],
typing.Union[test_dummy.components.responses.default.response.Response, test_dummy.paths.u_ltestu_l.get.responses.default.response.Response],
Responses({
'default': {
'application/json': test_dummy.paths.u_ltestu_l.get.responses.default.response.Response,
Expand All @@ -62,7 +60,7 @@ async def test_op(
async def inline_schema_properties(
self: typing.Self,
) -> typing.Annotated[
Awaitable[test_dummy.paths.u_linline_schema_propertiesu_l.get.responses.default.response.Response],
test_dummy.paths.u_linline_schema_propertiesu_l.get.responses.default.response.Response,
Responses({
'default': {
'application/json': test_dummy.paths.u_linline_schema_propertiesu_l.get.responses.default.response.Response,
Expand All @@ -75,7 +73,7 @@ async def inline_schema_properties(
async def customSecurity(
self: typing.Self,
) -> typing.Annotated[
Awaitable[test_dummy.paths.u_lcustomu_jsecurity.get.responses.default.response.Response],
test_dummy.paths.u_lcustomu_jsecurity.get.responses.default.response.Response,
Responses({
'default': {
'application/json': test_dummy.paths.u_lcustomu_jsecurity.get.responses.default.response.Response,
Expand All @@ -94,7 +92,7 @@ async def insecure(
}),
],
) -> typing.Annotated[
Awaitable[test_dummy.components.responses.default.response.Response],
test_dummy.components.responses.default.response.Response,
Responses({
'default': {
'application/json': test_dummy.components.responses.default.response.Response,
Expand Down
40 changes: 19 additions & 21 deletions tests/e2e/expected/petstore/gen/test_petstore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
'ApiClient',
]

from collections.abc import Awaitable

import typing_extensions as typing
from lapidary.runtime import *

Expand Down Expand Up @@ -57,7 +55,7 @@ async def updatePet(
}),
],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lpet.put.responses.u_o00.response.Response],
test_petstore.paths.u_lpet.put.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lpet.put.responses.u_o00.response.Response,
Expand All @@ -82,7 +80,7 @@ async def addPet(
}),
],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lpet.post.responses.u_o00.response.Response],
test_petstore.paths.u_lpet.post.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lpet.post.responses.u_o00.response.Response,
Expand All @@ -99,7 +97,7 @@ async def findPetsByStatus(
*,
status_q: typing.Annotated[typing.Union[None, str], Query('status', explode=True,)] = None,
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lpetu_lfindByStatus.get.responses.u_o00.response.Response],
test_petstore.paths.u_lpetu_lfindByStatus.get.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lpetu_lfindByStatus.get.responses.u_o00.response.Response,
Expand All @@ -116,7 +114,7 @@ async def findPetsByTags(
*,
tags_q: typing.Annotated[typing.Union[None, list[str]], Query('tags', explode=True,)] = None,
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lpetu_lfindByTags.get.responses.u_o00.response.Response],
test_petstore.paths.u_lpetu_lfindByTags.get.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lpetu_lfindByTags.get.responses.u_o00.response.Response,
Expand All @@ -133,7 +131,7 @@ async def getPetById(
*,
petId_p: typing.Annotated[int, Path('petId', )],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lpetu_lu_1zpetIdu_21.get.responses.u_o00.response.Response],
test_petstore.paths.u_lpetu_lu_1zpetIdu_21.get.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lpetu_lu_1zpetIdu_21.get.responses.u_o00.response.Response,
Expand All @@ -154,7 +152,7 @@ async def updatePetWithForm(
name_q: typing.Annotated[typing.Union[None, str], Query('name', )] = None,
status_q: typing.Annotated[typing.Union[None, str], Query('status', )] = None,
) -> typing.Annotated[
Awaitable[None],
None,
Responses({
'405': {
},
Expand All @@ -169,7 +167,7 @@ async def deletePet(
petId_p: typing.Annotated[int, Path('petId', )],
api_key_h: typing.Annotated[typing.Union[None, str], Header('api_key', )] = None,
) -> typing.Annotated[
Awaitable[None],
None,
Responses({
'400': {
},
Expand All @@ -184,7 +182,7 @@ async def uploadFile(
petId_p: typing.Annotated[int, Path('petId', )],
additionalMetadata_q: typing.Annotated[typing.Union[None, str], Query('additionalMetadata', )] = None,
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lpetu_lu_1zpetIdu_21u_luploadImage.post.responses.u_o00.response.Response],
test_petstore.paths.u_lpetu_lu_1zpetIdu_21u_luploadImage.post.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lpetu_lu_1zpetIdu_21u_luploadImage.post.responses.u_o00.response.Response,
Expand All @@ -197,7 +195,7 @@ async def uploadFile(
async def getInventory(
self: typing.Self,
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lstoreu_linventory.get.responses.u_o00.response.Response],
test_petstore.paths.u_lstoreu_linventory.get.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lstoreu_linventory.get.responses.u_o00.response.Response,
Expand All @@ -216,7 +214,7 @@ async def placeOrder(
}),
],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lstoreu_lorder.post.responses.u_o00.response.Response],
test_petstore.paths.u_lstoreu_lorder.post.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lstoreu_lorder.post.responses.u_o00.response.Response,
Expand All @@ -233,7 +231,7 @@ async def getOrderById(
*,
orderId_p: typing.Annotated[int, Path('orderId', )],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_lstoreu_lorderu_lu_1zorderIdu_21.get.responses.u_o00.response.Response],
test_petstore.paths.u_lstoreu_lorderu_lu_1zorderIdu_21.get.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_lstoreu_lorderu_lu_1zorderIdu_21.get.responses.u_o00.response.Response,
Expand All @@ -252,7 +250,7 @@ async def deleteOrder(
*,
orderId_p: typing.Annotated[int, Path('orderId', )],
) -> typing.Annotated[
Awaitable[None],
None,
Responses({
'400': {
},
Expand All @@ -272,7 +270,7 @@ async def createUser(
}),
],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_luser.post.responses.default.response.Response],
test_petstore.paths.u_luser.post.responses.default.response.Response,
Responses({
'default': {
'application/json': test_petstore.paths.u_luser.post.responses.default.response.Response,
Expand All @@ -291,7 +289,7 @@ async def createUsersWithListInput(
}),
],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_luseru_lcreateWithList.post.responses.u_o00.response.Response],
test_petstore.paths.u_luseru_lcreateWithList.post.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_luseru_lcreateWithList.post.responses.u_o00.response.Response,
Expand All @@ -309,7 +307,7 @@ async def loginUser(
username_q: typing.Annotated[typing.Union[None, str], Query('username', )] = None,
password_q: typing.Annotated[typing.Union[None, str], Query('password', )] = None,
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_luseru_llogin.get.responses.u_o00.response.Response],
test_petstore.paths.u_luseru_llogin.get.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_luseru_llogin.get.responses.u_o00.response.Response,
Expand All @@ -324,7 +322,7 @@ async def loginUser(
async def logoutUser(
self: typing.Self,
) -> typing.Annotated[
Awaitable[None],
None,
Responses({
'default': {
},
Expand All @@ -338,7 +336,7 @@ async def getUserByName(
*,
username_p: typing.Annotated[str, Path('username', )],
) -> typing.Annotated[
Awaitable[test_petstore.paths.u_luseru_lu_1zusernameu_21.get.responses.u_o00.response.Response],
test_petstore.paths.u_luseru_lu_1zusernameu_21.get.responses.u_o00.response.Response,
Responses({
'200': {
'application/json': test_petstore.paths.u_luseru_lu_1zusernameu_21.get.responses.u_o00.response.Response,
Expand All @@ -363,7 +361,7 @@ async def updateUser(
*,
username_p: typing.Annotated[str, Path('username', )],
) -> typing.Annotated[
Awaitable[None],
None,
Responses({
'default': {
},
Expand All @@ -377,7 +375,7 @@ async def deleteUser(
*,
username_p: typing.Annotated[str, Path('username', )],
) -> typing.Annotated[
Awaitable[None],
None,
Responses({
'400': {
},
Expand Down

0 comments on commit c74e054

Please sign in to comment.