Skip to content

Commit f79bccb

Browse files
fix: Remove Response[] from docstring of non-detailed functions (#741). Thanks @robertschweizer!
1 parent b754fd3 commit f79bccb

19 files changed

+45
-41
lines changed

end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def sync(
9191
httpx.TimeoutException: If the request takes longer than Client.timeout.
9292
9393
Returns:
94-
Response[PostResponsesUnionsSimpleBeforeComplexResponse200]
94+
PostResponsesUnionsSimpleBeforeComplexResponse200
9595
"""
9696

9797
return sync_detailed(
@@ -134,7 +134,7 @@ async def asyncio(
134134
httpx.TimeoutException: If the request takes longer than Client.timeout.
135135
136136
Returns:
137-
Response[PostResponsesUnionsSimpleBeforeComplexResponse200]
137+
PostResponsesUnionsSimpleBeforeComplexResponse200
138138
"""
139139

140140
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def sync(
106106
httpx.TimeoutException: If the request takes longer than Client.timeout.
107107
108108
Returns:
109-
Response[Union[Any, HTTPValidationError]]
109+
Union[Any, HTTPValidationError]
110110
"""
111111

112112
return sync_detailed(
@@ -163,7 +163,7 @@ async def asyncio(
163163
httpx.TimeoutException: If the request takes longer than Client.timeout.
164164
165165
Returns:
166-
Response[Union[Any, HTTPValidationError]]
166+
Union[Any, HTTPValidationError]
167167
"""
168168

169169
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def sync(
219219
httpx.TimeoutException: If the request takes longer than Client.timeout.
220220
221221
Returns:
222-
Response[Union[Any, HTTPValidationError]]
222+
Union[Any, HTTPValidationError]
223223
"""
224224

225225
return sync_detailed(
@@ -332,7 +332,7 @@ async def asyncio(
332332
httpx.TimeoutException: If the request takes longer than Client.timeout.
333333
334334
Returns:
335-
Response[Union[Any, HTTPValidationError]]
335+
Union[Any, HTTPValidationError]
336336
"""
337337

338338
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def sync(
8888
httpx.TimeoutException: If the request takes longer than Client.timeout.
8989
9090
Returns:
91-
Response[List[bool]]
91+
List[bool]
9292
"""
9393

9494
return sync_detailed(
@@ -135,7 +135,7 @@ async def asyncio(
135135
httpx.TimeoutException: If the request takes longer than Client.timeout.
136136
137137
Returns:
138-
Response[List[bool]]
138+
List[bool]
139139
"""
140140

141141
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def sync(
8888
httpx.TimeoutException: If the request takes longer than Client.timeout.
8989
9090
Returns:
91-
Response[List[float]]
91+
List[float]
9292
"""
9393

9494
return sync_detailed(
@@ -135,7 +135,7 @@ async def asyncio(
135135
httpx.TimeoutException: If the request takes longer than Client.timeout.
136136
137137
Returns:
138-
Response[List[float]]
138+
List[float]
139139
"""
140140

141141
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def sync(
8888
httpx.TimeoutException: If the request takes longer than Client.timeout.
8989
9090
Returns:
91-
Response[List[int]]
91+
List[int]
9292
"""
9393

9494
return sync_detailed(
@@ -135,7 +135,7 @@ async def asyncio(
135135
httpx.TimeoutException: If the request takes longer than Client.timeout.
136136
137137
Returns:
138-
Response[List[int]]
138+
List[int]
139139
"""
140140

141141
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def sync(
8888
httpx.TimeoutException: If the request takes longer than Client.timeout.
8989
9090
Returns:
91-
Response[List[str]]
91+
List[str]
9292
"""
9393

9494
return sync_detailed(
@@ -135,7 +135,7 @@ async def asyncio(
135135
httpx.TimeoutException: If the request takes longer than Client.timeout.
136136
137137
Returns:
138-
Response[List[str]]
138+
List[str]
139139
"""
140140

141141
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def sync(
173173
httpx.TimeoutException: If the request takes longer than Client.timeout.
174174
175175
Returns:
176-
Response[Union[HTTPValidationError, List['AModel']]]
176+
Union[HTTPValidationError, List['AModel']]
177177
"""
178178

179179
return sync_detailed(
@@ -248,7 +248,7 @@ async def asyncio(
248248
httpx.TimeoutException: If the request takes longer than Client.timeout.
249249
250250
Returns:
251-
Response[Union[HTTPValidationError, List['AModel']]]
251+
Union[HTTPValidationError, List['AModel']]
252252
"""
253253

254254
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def sync(
107107
httpx.TimeoutException: If the request takes longer than Client.timeout.
108108
109109
Returns:
110-
Response[Union[Any, HTTPValidationError]]
110+
Union[Any, HTTPValidationError]
111111
"""
112112

113113
return sync_detailed(
@@ -160,7 +160,7 @@ async def asyncio(
160160
httpx.TimeoutException: If the request takes longer than Client.timeout.
161161
162162
Returns:
163-
Response[Union[Any, HTTPValidationError]]
163+
Union[Any, HTTPValidationError]
164164
"""
165165

166166
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def sync(
106106
httpx.TimeoutException: If the request takes longer than Client.timeout.
107107
108108
Returns:
109-
Response[Union[Any, HTTPValidationError]]
109+
Union[Any, HTTPValidationError]
110110
"""
111111

112112
return sync_detailed(
@@ -163,7 +163,7 @@ async def asyncio(
163163
httpx.TimeoutException: If the request takes longer than Client.timeout.
164164
165165
Returns:
166-
Response[Union[Any, HTTPValidationError]]
166+
Union[Any, HTTPValidationError]
167167
"""
168168

169169
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def sync(
8585
httpx.TimeoutException: If the request takes longer than Client.timeout.
8686
8787
Returns:
88-
Response[File]
88+
File
8989
"""
9090

9191
return sync_detailed(
@@ -128,7 +128,7 @@ async def asyncio(
128128
httpx.TimeoutException: If the request takes longer than Client.timeout.
129129
130130
Returns:
131-
Response[File]
131+
File
132132
"""
133133

134134
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def sync(
101101
httpx.TimeoutException: If the request takes longer than Client.timeout.
102102
103103
Returns:
104-
Response[Union[HTTPValidationError, str]]
104+
Union[HTTPValidationError, str]
105105
"""
106106

107107
return sync_detailed(
@@ -154,7 +154,7 @@ async def asyncio(
154154
httpx.TimeoutException: If the request takes longer than Client.timeout.
155155
156156
Returns:
157-
Response[Union[HTTPValidationError, str]]
157+
Union[HTTPValidationError, str]
158158
"""
159159

160160
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def sync(
9999
httpx.TimeoutException: If the request takes longer than Client.timeout.
100100
101101
Returns:
102-
Response[TestInlineObjectsResponse200]
102+
TestInlineObjectsResponse200
103103
"""
104104

105105
return sync_detailed(
@@ -152,7 +152,7 @@ async def asyncio(
152152
httpx.TimeoutException: If the request takes longer than Client.timeout.
153153
154154
Returns:
155-
Response[TestInlineObjectsResponse200]
155+
TestInlineObjectsResponse200
156156
"""
157157

158158
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def sync(
106106
httpx.TimeoutException: If the request takes longer than Client.timeout.
107107
108108
Returns:
109-
Response[Union[Any, HTTPValidationError]]
109+
Union[Any, HTTPValidationError]
110110
"""
111111

112112
return sync_detailed(
@@ -163,7 +163,7 @@ async def asyncio(
163163
httpx.TimeoutException: If the request takes longer than Client.timeout.
164164
165165
Returns:
166-
Response[Union[Any, HTTPValidationError]]
166+
Union[Any, HTTPValidationError]
167167
"""
168168

169169
return (

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def sync(
109109
httpx.TimeoutException: If the request takes longer than Client.timeout.
110110
111111
Returns:
112-
Response[Union[Any, HTTPValidationError]]
112+
Union[Any, HTTPValidationError]
113113
"""
114114

115115
return sync_detailed(
@@ -166,7 +166,7 @@ async def asyncio(
166166
httpx.TimeoutException: If the request takes longer than Client.timeout.
167167
168168
Returns:
169-
Response[Union[Any, HTTPValidationError]]
169+
Union[Any, HTTPValidationError]
170170
"""
171171

172172
return (

integration-tests/integration_tests/api/body/post_body_multipart.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def sync(
106106
httpx.TimeoutException: If the request takes longer than Client.timeout.
107107
108108
Returns:
109-
Response[Union[PostBodyMultipartResponse200, PublicError]]
109+
Union[PostBodyMultipartResponse200, PublicError]
110110
"""
111111

112112
return sync_detailed(
@@ -157,7 +157,7 @@ async def asyncio(
157157
httpx.TimeoutException: If the request takes longer than Client.timeout.
158158
159159
Returns:
160-
Response[Union[PostBodyMultipartResponse200, PublicError]]
160+
Union[PostBodyMultipartResponse200, PublicError]
161161
"""
162162

163163
return (

integration-tests/integration_tests/api/parameters/post_parameters_header.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def sync(
128128
httpx.TimeoutException: If the request takes longer than Client.timeout.
129129
130130
Returns:
131-
Response[Union[PostParametersHeaderResponse200, PublicError]]
131+
Union[PostParametersHeaderResponse200, PublicError]
132132
"""
133133

134134
return sync_detailed(
@@ -197,7 +197,7 @@ async def asyncio(
197197
httpx.TimeoutException: If the request takes longer than Client.timeout.
198198
199199
Returns:
200-
Response[Union[PostParametersHeaderResponse200, PublicError]]
200+
Union[PostParametersHeaderResponse200, PublicError]
201201
"""
202202

203203
return (

openapi_python_client/templates/endpoint_macros.py.jinja

+7-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ json_body=json_body,
141141
{% endfor %}
142142
{% endmacro %}
143143

144-
{% macro docstring_content(endpoint, return_string) %}
144+
{% macro docstring_content(endpoint, return_string, is_detailed) %}
145145
{% if endpoint.summary %}{{ endpoint.summary | wordwrap(100)}}
146146

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

167167
Returns:
168+
{% if is_detailed %}
168169
Response[{{ return_string }}]
170+
{% else %}
171+
{{ return_string }}
172+
{% endif %}
169173
{% endmacro %}
170174

171-
{% macro docstring(endpoint, return_string) %}
172-
{{ safe_docstring(docstring_content(endpoint, return_string)) }}
175+
{% macro docstring(endpoint, return_string, is_detailed) %}
176+
{{ safe_docstring(docstring_content(endpoint, return_string, is_detailed)) }}
173177
{% endmacro %}

openapi_python_client/templates/endpoint_module.py.jinja

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[{{
9292
def sync_detailed(
9393
{{ arguments(endpoint) | indent(4) }}
9494
) -> Response[{{ return_string }}]:
95-
{{ docstring(endpoint, return_string) | indent(4) }}
95+
{{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }}
9696

9797
kwargs = _get_kwargs(
9898
{{ kwargs(endpoint) }}
@@ -109,7 +109,7 @@ def sync_detailed(
109109
def sync(
110110
{{ arguments(endpoint) | indent(4) }}
111111
) -> Optional[{{ return_string }}]:
112-
{{ docstring(endpoint, return_string) | indent(4) }}
112+
{{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }}
113113

114114
return sync_detailed(
115115
{{ kwargs(endpoint) }}
@@ -119,7 +119,7 @@ def sync(
119119
async def asyncio_detailed(
120120
{{ arguments(endpoint) | indent(4) }}
121121
) -> Response[{{ return_string }}]:
122-
{{ docstring(endpoint, return_string) | indent(4) }}
122+
{{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }}
123123

124124
kwargs = _get_kwargs(
125125
{{ kwargs(endpoint) }}
@@ -136,7 +136,7 @@ async def asyncio_detailed(
136136
async def asyncio(
137137
{{ arguments(endpoint) | indent(4) }}
138138
) -> Optional[{{ return_string }}]:
139-
{{ docstring(endpoint, return_string) | indent(4) }}
139+
{{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }}
140140

141141
return (await asyncio_detailed(
142142
{{ kwargs(endpoint) }}

0 commit comments

Comments
 (0)