Skip to content

Commit 14ece43

Browse files
fix: Add None to Response[] generic type
Also prevents double return type annotations like `Optional[None]`.
1 parent 5a75e3d commit 14ece43

37 files changed

+273
-271
lines changed

end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -34,7 +34,7 @@ def _get_kwargs(
3434
}
3535

3636

37-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
37+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
3838
if response.status_code == HTTPStatus.OK:
3939
return None
4040
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -34,7 +34,7 @@ def _get_kwargs(
3434
}
3535

3636

37-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
37+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
3838
if response.status_code == HTTPStatus.OK:
3939
return None
4040
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -53,7 +53,7 @@ def _get_kwargs(
5353
}
5454

5555

56-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
56+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
5757
if response.status_code == HTTPStatus.OK:
5858
return None
5959
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from http import HTTPStatus
3-
from typing import Any, Dict, Optional, Union
3+
from typing import Any, Dict, Union
44

55
import httpx
66

@@ -58,7 +58,7 @@ def _get_kwargs(
5858
}
5959

6060

61-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
61+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
6262
if response.status_code == HTTPStatus.OK:
6363
return None
6464
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -46,7 +46,7 @@ def _get_kwargs(
4646
}
4747

4848

49-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
49+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
5050
if response.status_code == HTTPStatus.OK:
5151
return None
5252
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -35,7 +35,7 @@ def _get_kwargs(
3535
}
3636

3737

38-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
38+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
3939
if response.status_code == HTTPStatus.OK:
4040
return None
4141
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict
33

44
import httpx
55

@@ -35,7 +35,7 @@ def _get_kwargs(
3535
}
3636

3737

38-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
38+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
3939
if response.status_code == HTTPStatus.OK:
4040
return None
4141
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -43,7 +43,7 @@ def _get_kwargs(
4343
}
4444

4545

46-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
46+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
4747
if response.status_code == HTTPStatus.OK:
4848
return None
4949
if client.raise_on_unexpected_status:

end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict
33

44
import httpx
55

@@ -33,7 +33,7 @@ def _get_kwargs(
3333
}
3434

3535

36-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
36+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
3737
if response.status_code == HTTPStatus.OK:
3838
return None
3939
if client.raise_on_unexpected_status:

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -32,7 +32,7 @@ def _get_kwargs(
3232

3333
def _parse_response(
3434
*, client: Client, response: httpx.Response
35-
) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]:
35+
) -> Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]:
3636
if response.status_code == HTTPStatus.OK:
3737
response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json())
3838

@@ -45,7 +45,7 @@ def _parse_response(
4545

4646
def _build_response(
4747
*, client: Client, response: httpx.Response
48-
) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]:
48+
) -> Response[Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]]:
4949
return Response(
5050
status_code=HTTPStatus(response.status_code),
5151
content=response.content,
@@ -57,15 +57,15 @@ def _build_response(
5757
def sync_detailed(
5858
*,
5959
client: Client,
60-
) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]:
60+
) -> Response[Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]]:
6161
"""Regression test for #603
6262
6363
Raises:
6464
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
6565
httpx.TimeoutException: If the request takes longer than Client.timeout.
6666
6767
Returns:
68-
Response[PostResponsesUnionsSimpleBeforeComplexResponse200]
68+
Response[Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]]
6969
"""
7070

7171
kwargs = _get_kwargs(
@@ -83,15 +83,15 @@ def sync_detailed(
8383
def sync(
8484
*,
8585
client: Client,
86-
) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]:
86+
) -> Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]:
8787
"""Regression test for #603
8888
8989
Raises:
9090
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
9191
httpx.TimeoutException: If the request takes longer than Client.timeout.
9292
9393
Returns:
94-
PostResponsesUnionsSimpleBeforeComplexResponse200
94+
Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]
9595
"""
9696

9797
return sync_detailed(
@@ -102,15 +102,15 @@ def sync(
102102
async def asyncio_detailed(
103103
*,
104104
client: Client,
105-
) -> Response[PostResponsesUnionsSimpleBeforeComplexResponse200]:
105+
) -> Response[Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]]:
106106
"""Regression test for #603
107107
108108
Raises:
109109
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
110110
httpx.TimeoutException: If the request takes longer than Client.timeout.
111111
112112
Returns:
113-
Response[PostResponsesUnionsSimpleBeforeComplexResponse200]
113+
Response[Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]]
114114
"""
115115

116116
kwargs = _get_kwargs(
@@ -126,15 +126,15 @@ async def asyncio_detailed(
126126
async def asyncio(
127127
*,
128128
client: Client,
129-
) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]:
129+
) -> Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]:
130130
"""Regression test for #603
131131
132132
Raises:
133133
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134134
httpx.TimeoutException: If the request takes longer than Client.timeout.
135135
136136
Returns:
137-
PostResponsesUnionsSimpleBeforeComplexResponse200
137+
Union[None, PostResponsesUnionsSimpleBeforeComplexResponse200]
138138
"""
139139

140140
return (

end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict
33

44
import httpx
55

@@ -27,7 +27,7 @@ def _get_kwargs(
2727
}
2828

2929

30-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[None]:
30+
def _parse_response(*, client: Client, response: httpx.Response) -> None:
3131
if response.status_code == HTTPStatus.OK:
3232
return None
3333
if client.raise_on_unexpected_status:

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Union
33

44
import httpx
55

@@ -33,7 +33,7 @@ def _get_kwargs(
3333
}
3434

3535

36-
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
36+
def _parse_response(*, client: Client, response: httpx.Response) -> Union[Any, HTTPValidationError, None]:
3737
if response.status_code == HTTPStatus.OK:
3838
response_200 = response.json()
3939
return response_200
@@ -47,7 +47,7 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Uni
4747
return None
4848

4949

50-
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError]]:
50+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Any, HTTPValidationError, None]]:
5151
return Response(
5252
status_code=HTTPStatus(response.status_code),
5353
content=response.content,
@@ -60,7 +60,7 @@ def sync_detailed(
6060
*,
6161
client: Client,
6262
json_body: AModel,
63-
) -> Response[Union[Any, HTTPValidationError]]:
63+
) -> Response[Union[Any, HTTPValidationError, None]]:
6464
"""Path with callback
6565
6666
Try sending a request related to a callback
@@ -73,7 +73,7 @@ def sync_detailed(
7373
httpx.TimeoutException: If the request takes longer than Client.timeout.
7474
7575
Returns:
76-
Response[Union[Any, HTTPValidationError]]
76+
Response[Union[Any, HTTPValidationError, None]]
7777
"""
7878

7979
kwargs = _get_kwargs(
@@ -93,7 +93,7 @@ def sync(
9393
*,
9494
client: Client,
9595
json_body: AModel,
96-
) -> Optional[Union[Any, HTTPValidationError]]:
96+
) -> Union[Any, HTTPValidationError, None]:
9797
"""Path with callback
9898
9999
Try sending a request related to a callback
@@ -106,7 +106,7 @@ def sync(
106106
httpx.TimeoutException: If the request takes longer than Client.timeout.
107107
108108
Returns:
109-
Union[Any, HTTPValidationError]
109+
Union[Any, HTTPValidationError, None]
110110
"""
111111

112112
return sync_detailed(
@@ -119,7 +119,7 @@ async def asyncio_detailed(
119119
*,
120120
client: Client,
121121
json_body: AModel,
122-
) -> Response[Union[Any, HTTPValidationError]]:
122+
) -> Response[Union[Any, HTTPValidationError, None]]:
123123
"""Path with callback
124124
125125
Try sending a request related to a callback
@@ -132,7 +132,7 @@ async def asyncio_detailed(
132132
httpx.TimeoutException: If the request takes longer than Client.timeout.
133133
134134
Returns:
135-
Response[Union[Any, HTTPValidationError]]
135+
Response[Union[Any, HTTPValidationError, None]]
136136
"""
137137

138138
kwargs = _get_kwargs(
@@ -150,7 +150,7 @@ async def asyncio(
150150
*,
151151
client: Client,
152152
json_body: AModel,
153-
) -> Optional[Union[Any, HTTPValidationError]]:
153+
) -> Union[Any, HTTPValidationError, None]:
154154
"""Path with callback
155155
156156
Try sending a request related to a callback
@@ -163,7 +163,7 @@ async def asyncio(
163163
httpx.TimeoutException: If the request takes longer than Client.timeout.
164164
165165
Returns:
166-
Union[Any, HTTPValidationError]
166+
Union[Any, HTTPValidationError, None]
167167
"""
168168

169169
return (

0 commit comments

Comments
 (0)