Skip to content

Commit df4618b

Browse files
committed
fix: error handling
1 parent 306c2e0 commit df4618b

53 files changed

Lines changed: 605 additions & 742 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Any, Optional
1+
from typing import TYPE_CHECKING, Any
22

33
if TYPE_CHECKING:
44
from ...client import MyTestApiClient
@@ -17,13 +17,13 @@ def get_common_parameters(
1717
self,
1818
*,
1919
common: Union[Unset, None, str] = UNSET,
20-
) -> Optional[Any]:
20+
) -> Any:
2121
"""
2222
Args:
2323
common (Union[Unset, None, str]):
2424
2525
Raises:
26-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
26+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
2727
httpx.TimeoutException: If the request takes longer than Client.timeout.
2828
2929
Returns:
@@ -39,13 +39,13 @@ async def get_common_parameters_async(
3939
self,
4040
*,
4141
common: Union[Unset, None, str] = UNSET,
42-
) -> Optional[Any]:
42+
) -> Any:
4343
"""
4444
Args:
4545
common (Union[Unset, None, str]):
4646
4747
Raises:
48-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
48+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
4949
httpx.TimeoutException: If the request takes longer than Client.timeout.
5050
5151
Returns:
@@ -61,13 +61,13 @@ def post_common_parameters(
6161
self,
6262
*,
6363
common: Union[Unset, None, str] = UNSET,
64-
) -> Optional[Any]:
64+
) -> Any:
6565
"""
6666
Args:
6767
common (Union[Unset, None, str]):
6868
6969
Raises:
70-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
70+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
7171
httpx.TimeoutException: If the request takes longer than Client.timeout.
7272
7373
Returns:
@@ -83,13 +83,13 @@ async def post_common_parameters_async(
8383
self,
8484
*,
8585
common: Union[Unset, None, str] = UNSET,
86-
) -> Optional[Any]:
86+
) -> Any:
8787
"""
8888
Args:
8989
common (Union[Unset, None, str]):
9090
9191
Raises:
92-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
92+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
9393
httpx.TimeoutException: If the request takes longer than Client.timeout.
9494
9595
Returns:

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

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

44
import httpx
55

66
if TYPE_CHECKING:
77
from ...client import MyTestApiClient
88

9-
from typing import Optional, Union
9+
from typing import Union
1010

1111
from ... import errors
1212
from ...types import UNSET, Response, Unset
@@ -34,13 +34,11 @@ def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiCl
3434
}
3535

3636

37-
def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]:
37+
def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any:
3838
if response.status_code == HTTPStatus.OK:
39-
return None
40-
if client.raise_on_unexpected_status:
41-
raise errors.UnexpectedStatus(response.status_code, response.content)
42-
else:
43-
return None
39+
response_200 = None
40+
return response_200
41+
raise errors.UnexpectedStatus(response.status_code, response.content)
4442

4543

4644
def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]:
@@ -58,7 +56,7 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi
5856
common (Union[Unset, None, str]):
5957
6058
Raises:
61-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
59+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
6260
httpx.TimeoutException: If the request takes longer than Client.timeout.
6361
6462
Returns:
@@ -78,13 +76,13 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi
7876
return _build_response(client=client, response=response)
7977

8078

81-
def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]:
79+
def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any:
8280
"""
8381
Args:
8482
common (Union[Unset, None, str]):
8583
8684
Raises:
87-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
85+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
8886
httpx.TimeoutException: If the request takes longer than Client.timeout.
8987
9088
Returns:
@@ -103,7 +101,7 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: "
103101
common (Union[Unset, None, str]):
104102
105103
Raises:
106-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
104+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
107105
httpx.TimeoutException: If the request takes longer than Client.timeout.
108106
109107
Returns:
@@ -121,13 +119,13 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: "
121119
return _build_response(client=client, response=response)
122120

123121

124-
async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]:
122+
async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any:
125123
"""
126124
Args:
127125
common (Union[Unset, None, str]):
128126
129127
Raises:
130-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
128+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
131129
httpx.TimeoutException: If the request takes longer than Client.timeout.
132130
133131
Returns:

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

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

44
import httpx
55

66
if TYPE_CHECKING:
77
from ...client import MyTestApiClient
88

9-
from typing import Optional, Union
9+
from typing import Union
1010

1111
from ... import errors
1212
from ...types import UNSET, Response, Unset
@@ -34,13 +34,11 @@ def _get_kwargs(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiCl
3434
}
3535

3636

37-
def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]:
37+
def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any:
3838
if response.status_code == HTTPStatus.OK:
39-
return None
40-
if client.raise_on_unexpected_status:
41-
raise errors.UnexpectedStatus(response.status_code, response.content)
42-
else:
43-
return None
39+
response_200 = None
40+
return response_200
41+
raise errors.UnexpectedStatus(response.status_code, response.content)
4442

4543

4644
def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]:
@@ -58,7 +56,7 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi
5856
common (Union[Unset, None, str]):
5957
6058
Raises:
61-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
59+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
6260
httpx.TimeoutException: If the request takes longer than Client.timeout.
6361
6462
Returns:
@@ -78,13 +76,13 @@ def sync_detailed(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApi
7876
return _build_response(client=client, response=response)
7977

8078

81-
def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]:
79+
def sync(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any:
8280
"""
8381
Args:
8482
common (Union[Unset, None, str]):
8583
8684
Raises:
87-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
85+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
8886
httpx.TimeoutException: If the request takes longer than Client.timeout.
8987
9088
Returns:
@@ -103,7 +101,7 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: "
103101
common (Union[Unset, None, str]):
104102
105103
Raises:
106-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
104+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
107105
httpx.TimeoutException: If the request takes longer than Client.timeout.
108106
109107
Returns:
@@ -121,13 +119,13 @@ async def asyncio_detailed(*, common: Union[Unset, None, str] = UNSET, client: "
121119
return _build_response(client=client, response=response)
122120

123121

124-
async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Optional[Any]:
122+
async def asyncio(*, common: Union[Unset, None, str] = UNSET, client: "MyTestApiClient") -> Any:
125123
"""
126124
Args:
127125
common (Union[Unset, None, str]):
128126
129127
Raises:
130-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
128+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
131129
httpx.TimeoutException: If the request takes longer than Client.timeout.
132130
133131
Returns:

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Any, Optional
1+
from typing import TYPE_CHECKING, Any
22

33
if TYPE_CHECKING:
44
from ...client import MyTestApiClient
@@ -25,7 +25,7 @@ def get_location_query_optionality(
2525
null_required: Union[Unset, None, datetime.datetime] = UNSET,
2626
null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
2727
not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
28-
) -> Optional[Any]:
28+
) -> Any:
2929
"""
3030
Args:
3131
not_null_required (datetime.datetime):
@@ -34,7 +34,7 @@ def get_location_query_optionality(
3434
not_null_not_required (Union[Unset, None, datetime.datetime]):
3535
3636
Raises:
37-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
37+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
3838
httpx.TimeoutException: If the request takes longer than Client.timeout.
3939
4040
Returns:
@@ -56,7 +56,7 @@ async def get_location_query_optionality_async(
5656
null_required: Union[Unset, None, datetime.datetime] = UNSET,
5757
null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
5858
not_null_not_required: Union[Unset, None, datetime.datetime] = UNSET,
59-
) -> Optional[Any]:
59+
) -> Any:
6060
"""
6161
Args:
6262
not_null_required (datetime.datetime):
@@ -65,7 +65,7 @@ async def get_location_query_optionality_async(
6565
not_null_not_required (Union[Unset, None, datetime.datetime]):
6666
6767
Raises:
68-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
68+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
6969
httpx.TimeoutException: If the request takes longer than Client.timeout.
7070
7171
Returns:
@@ -89,7 +89,7 @@ def get_location_header_types(
8989
integer_header: Union[Unset, int] = UNSET,
9090
int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET,
9191
string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET,
92-
) -> Optional[Any]:
92+
) -> Any:
9393
"""
9494
Args:
9595
boolean_header (Union[Unset, bool]):
@@ -100,7 +100,7 @@ def get_location_header_types(
100100
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):
101101
102102
Raises:
103-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
103+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
104104
httpx.TimeoutException: If the request takes longer than Client.timeout.
105105
106106
Returns:
@@ -126,7 +126,7 @@ async def get_location_header_types_async(
126126
integer_header: Union[Unset, int] = UNSET,
127127
int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET,
128128
string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET,
129-
) -> Optional[Any]:
129+
) -> Any:
130130
"""
131131
Args:
132132
boolean_header (Union[Unset, bool]):
@@ -137,7 +137,7 @@ async def get_location_header_types_async(
137137
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):
138138
139139
Raises:
140-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
140+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
141141
httpx.TimeoutException: If the request takes longer than Client.timeout.
142142
143143
Returns:

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

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

44
import httpx
55

@@ -57,13 +57,11 @@ def _get_kwargs(
5757
}
5858

5959

60-
def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Optional[Any]:
60+
def _parse_response(*, client: "MyTestApiClient", response: httpx.Response) -> Any:
6161
if response.status_code == HTTPStatus.OK:
62-
return None
63-
if client.raise_on_unexpected_status:
64-
raise errors.UnexpectedStatus(response.status_code, response.content)
65-
else:
66-
return None
62+
response_200 = None
63+
return response_200
64+
raise errors.UnexpectedStatus(response.status_code, response.content)
6765

6866

6967
def _build_response(*, client: "MyTestApiClient", response: httpx.Response) -> Response[Any]:
@@ -95,7 +93,7 @@ def sync_detailed(
9593
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):
9694
9795
Raises:
98-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
96+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
9997
httpx.TimeoutException: If the request takes longer than Client.timeout.
10098
10199
Returns:
@@ -129,7 +127,7 @@ def sync(
129127
int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET,
130128
string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET,
131129
client: "MyTestApiClient",
132-
) -> Optional[Any]:
130+
) -> Any:
133131
"""
134132
Args:
135133
boolean_header (Union[Unset, bool]):
@@ -140,7 +138,7 @@ def sync(
140138
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):
141139
142140
Raises:
143-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
141+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
144142
httpx.TimeoutException: If the request takes longer than Client.timeout.
145143
146144
Returns:
@@ -178,7 +176,7 @@ async def asyncio_detailed(
178176
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):
179177
180178
Raises:
181-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
179+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
182180
httpx.TimeoutException: If the request takes longer than Client.timeout.
183181
184182
Returns:
@@ -210,7 +208,7 @@ async def asyncio(
210208
int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET,
211209
string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET,
212210
client: "MyTestApiClient",
213-
) -> Optional[Any]:
211+
) -> Any:
214212
"""
215213
Args:
216214
boolean_header (Union[Unset, bool]):
@@ -221,7 +219,7 @@ async def asyncio(
221219
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):
222220
223221
Raises:
224-
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
222+
errors.UnexpectedStatus: If the server returns a non 2xx status code.
225223
httpx.TimeoutException: If the request takes longer than Client.timeout.
226224
227225
Returns:

0 commit comments

Comments
 (0)