Skip to content

fix: Remove Response[] from docstring of non-detailed functions #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[PostResponsesUnionsSimpleBeforeComplexResponse200]
PostResponsesUnionsSimpleBeforeComplexResponse200
"""

return sync_detailed(
Expand Down Expand Up @@ -134,7 +134,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[PostResponsesUnionsSimpleBeforeComplexResponse200]
PostResponsesUnionsSimpleBeforeComplexResponse200
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return sync_detailed(
Expand Down Expand Up @@ -163,7 +163,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return sync_detailed(
Expand Down Expand Up @@ -332,7 +332,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[bool]]
List[bool]
"""

return sync_detailed(
Expand Down Expand Up @@ -135,7 +135,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[bool]]
List[bool]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[float]]
List[float]
"""

return sync_detailed(
Expand Down Expand Up @@ -135,7 +135,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[float]]
List[float]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[int]]
List[int]
"""

return sync_detailed(
Expand Down Expand Up @@ -135,7 +135,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[int]]
List[int]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[str]]
List[str]
"""

return sync_detailed(
Expand Down Expand Up @@ -135,7 +135,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[List[str]]
List[str]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[HTTPValidationError, List['AModel']]]
Union[HTTPValidationError, List['AModel']]
"""

return sync_detailed(
Expand Down Expand Up @@ -248,7 +248,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[HTTPValidationError, List['AModel']]]
Union[HTTPValidationError, List['AModel']]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return sync_detailed(
Expand Down Expand Up @@ -160,7 +160,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return sync_detailed(
Expand Down Expand Up @@ -163,7 +163,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[File]
File
"""

return sync_detailed(
Expand Down Expand Up @@ -128,7 +128,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[File]
File
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[HTTPValidationError, str]]
Union[HTTPValidationError, str]
"""

return sync_detailed(
Expand Down Expand Up @@ -154,7 +154,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[HTTPValidationError, str]]
Union[HTTPValidationError, str]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[TestInlineObjectsResponse200]
TestInlineObjectsResponse200
"""

return sync_detailed(
Expand Down Expand Up @@ -152,7 +152,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[TestInlineObjectsResponse200]
TestInlineObjectsResponse200
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return sync_detailed(
Expand Down Expand Up @@ -163,7 +163,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return sync_detailed(
Expand Down Expand Up @@ -166,7 +166,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, HTTPValidationError]]
Union[Any, HTTPValidationError]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[PostBodyMultipartResponse200, PublicError]]
Union[PostBodyMultipartResponse200, PublicError]
"""

return sync_detailed(
Expand Down Expand Up @@ -157,7 +157,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[PostBodyMultipartResponse200, PublicError]]
Union[PostBodyMultipartResponse200, PublicError]
"""

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[PostParametersHeaderResponse200, PublicError]]
Union[PostParametersHeaderResponse200, PublicError]
"""

return sync_detailed(
Expand Down Expand Up @@ -197,7 +197,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[PostParametersHeaderResponse200, PublicError]]
Union[PostParametersHeaderResponse200, PublicError]
"""

return (
Expand Down
10 changes: 7 additions & 3 deletions openapi_python_client/templates/endpoint_macros.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ json_body=json_body,
{% endfor %}
{% endmacro %}

{% macro docstring_content(endpoint, return_string) %}
{% macro docstring_content(endpoint, return_string, is_detailed) %}
{% if endpoint.summary %}{{ endpoint.summary | wordwrap(100)}}

{% endif -%}
Expand All @@ -165,9 +165,13 @@ Raises:
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
{% if is_detailed %}
Response[{{ return_string }}]
{% else %}
{{ return_string }}
{% endif %}
{% endmacro %}

{% macro docstring(endpoint, return_string) %}
{{ safe_docstring(docstring_content(endpoint, return_string)) }}
{% macro docstring(endpoint, return_string, is_detailed) %}
{{ safe_docstring(docstring_content(endpoint, return_string, is_detailed)) }}
{% endmacro %}
8 changes: 4 additions & 4 deletions openapi_python_client/templates/endpoint_module.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[{{
def sync_detailed(
{{ arguments(endpoint) | indent(4) }}
) -> Response[{{ return_string }}]:
{{ docstring(endpoint, return_string) | indent(4) }}
{{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }}

kwargs = _get_kwargs(
{{ kwargs(endpoint) }}
Expand All @@ -109,7 +109,7 @@ def sync_detailed(
def sync(
{{ arguments(endpoint) | indent(4) }}
) -> Optional[{{ return_string }}]:
{{ docstring(endpoint, return_string) | indent(4) }}
{{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }}

return sync_detailed(
{{ kwargs(endpoint) }}
Expand All @@ -119,7 +119,7 @@ def sync(
async def asyncio_detailed(
{{ arguments(endpoint) | indent(4) }}
) -> Response[{{ return_string }}]:
{{ docstring(endpoint, return_string) | indent(4) }}
{{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }}

kwargs = _get_kwargs(
{{ kwargs(endpoint) }}
Expand All @@ -136,7 +136,7 @@ async def asyncio_detailed(
async def asyncio(
{{ arguments(endpoint) | indent(4) }}
) -> Optional[{{ return_string }}]:
{{ docstring(endpoint, return_string) | indent(4) }}
{{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }}

return (await asyncio_detailed(
{{ kwargs(endpoint) }}
Expand Down