Skip to content

Commit cd3e70b

Browse files
authored
Support Python 3.13 (#1046)
TODO: - [x] Use backwards-compatible `HTTPStatus` enum variants so clients generated on 3.13 can be run on older versions --------- Co-authored-by: Dylan Anthony <[email protected]>
1 parent 8864a5f commit cd3e70b

File tree

56 files changed

+81
-67
lines changed

Some content is hidden

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

56 files changed

+81
-67
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
default: patch
3+
---
4+
5+
# Use literal value instead of `HTTPStatus` enum when checking response statuses
6+
7+
Python 3.13 renamed some of the `HTTPStatus` enum members, which means clients generated with Python 3.13 may not work
8+
with older versions of Python. This change stops using the `HTTPStatus` enum directly when checking response statuses.
9+
10+
Statuses will still be checked for validity at generation time, and transformed into `HTTPStatus` _after_ being checked
11+
at runtime.
12+
13+
This may cause some linters to complain.

.github/workflows/checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
test:
1212
strategy:
1313
matrix:
14-
python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
14+
python: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
1515
os: [ ubuntu-latest, macos-latest, windows-latest ]
1616
runs-on: ${{ matrix.os }}
1717
steps:

end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _get_kwargs(
3030

3131

3232
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
33-
if response.status_code == HTTPStatus.OK:
33+
if response.status_code == 200:
3434
return None
3535
if client.raise_on_unexpected_status:
3636
raise errors.UnexpectedStatus(response.status_code, response.content)

end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _get_kwargs(
5353

5454

5555
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
56-
if response.status_code == HTTPStatus.OK:
56+
if response.status_code == 200:
5757
return None
5858
if client.raise_on_unexpected_status:
5959
raise errors.UnexpectedStatus(response.status_code, response.content)

end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _get_kwargs(
3030

3131

3232
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
33-
if response.status_code == HTTPStatus.OK:
33+
if response.status_code == 200:
3434
return None
3535
if client.raise_on_unexpected_status:
3636
raise errors.UnexpectedStatus(response.status_code, response.content)

end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _get_kwargs(
2929

3030

3131
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]:
32-
if response.status_code == HTTPStatus.OK:
32+
if response.status_code == 200:
3333
response_200 = cast(str, response.json())
3434
return response_200
3535
if client.raise_on_unexpected_status:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _get_kwargs(
2828

2929

3030
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
31-
if response.status_code == HTTPStatus.OK:
31+
if response.status_code == 200:
3232
return None
3333
if client.raise_on_unexpected_status:
3434
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _get_kwargs() -> Dict[str, Any]:
2121
def _parse_response(
2222
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
2323
) -> Optional[GetModelsAllofResponse200]:
24-
if response.status_code == HTTPStatus.OK:
24+
if response.status_code == 200:
2525
response_200 = GetModelsAllofResponse200.from_dict(response.json())
2626

2727
return response_200

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _get_kwargs(
2828

2929

3030
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
31-
if response.status_code == HTTPStatus.OK:
31+
if response.status_code == 200:
3232
return None
3333
if client.raise_on_unexpected_status:
3434
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _get_kwargs(
3131

3232

3333
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
34-
if response.status_code == HTTPStatus.OK:
34+
if response.status_code == 200:
3535
return None
3636
if client.raise_on_unexpected_status:
3737
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def _get_kwargs(
8989
def _parse_response(
9090
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
9191
) -> Optional[Union[Any, HTTPValidationError]]:
92-
if response.status_code == HTTPStatus.OK:
92+
if response.status_code == 200:
9393
response_200 = response.json()
9494
return response_200
95-
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
95+
if response.status_code == 422:
9696
response_422 = HTTPValidationError.from_dict(response.json())
9797

9898
return response_422

end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _get_kwargs(
2828

2929

3030
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
31-
if response.status_code == HTTPStatus.OK:
31+
if response.status_code == 200:
3232
return None
3333
if client.raise_on_unexpected_status:
3434
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _get_kwargs(
3030

3131

3232
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
33-
if response.status_code == HTTPStatus.OK:
33+
if response.status_code == 200:
3434
return None
3535
if client.raise_on_unexpected_status:
3636
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _get_kwargs(
4848

4949

5050
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
51-
if response.status_code == HTTPStatus.OK:
51+
if response.status_code == 200:
5252
return None
5353
if client.raise_on_unexpected_status:
5454
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _get_kwargs(
5454

5555

5656
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
57-
if response.status_code == HTTPStatus.OK:
57+
if response.status_code == 200:
5858
return None
5959
if client.raise_on_unexpected_status:
6060
raise errors.UnexpectedStatus(response.status_code, response.content)

end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _get_kwargs(
2020

2121

2222
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
23-
if response.status_code == HTTPStatus.OK:
23+
if response.status_code == 200:
2424
return None
2525
if client.raise_on_unexpected_status:
2626
raise errors.UnexpectedStatus(response.status_code, response.content)

end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _get_kwargs(
3434
def _parse_response(
3535
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
3636
) -> Optional[MixedCaseResponse200]:
37-
if response.status_code == HTTPStatus.OK:
37+
if response.status_code == 200:
3838
response_200 = MixedCaseResponse200.from_dict(response.json())
3939

4040
return response_200

end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _get_kwargs(
3535
def _parse_response(
3636
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
3737
) -> Optional[PostNamingPropertyConflictWithImportResponse200]:
38-
if response.status_code == HTTPStatus.OK:
38+
if response.status_code == 200:
3939
response_200 = PostNamingPropertyConflictWithImportResponse200.from_dict(response.json())
4040

4141
return response_200

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _get_kwargs(
4444

4545

4646
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
47-
if response.status_code == HTTPStatus.OK:
47+
if response.status_code == 200:
4848
return None
4949
if client.raise_on_unexpected_status:
5050
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _get_kwargs(
2929

3030

3131
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
32-
if response.status_code == HTTPStatus.OK:
32+
if response.status_code == 200:
3333
return None
3434
if client.raise_on_unexpected_status:
3535
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _get_kwargs(
2929

3030

3131
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
32-
if response.status_code == HTTPStatus.OK:
32+
if response.status_code == 200:
3333
return None
3434
if client.raise_on_unexpected_status:
3535
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _get_kwargs(
4141

4242

4343
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
44-
if response.status_code == HTTPStatus.OK:
44+
if response.status_code == 200:
4545
return None
4646
if client.raise_on_unexpected_status:
4747
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _get_kwargs(
2323

2424

2525
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
26-
if response.status_code == HTTPStatus.OK:
26+
if response.status_code == 200:
2727
return None
2828
if client.raise_on_unexpected_status:
2929
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _get_kwargs() -> Dict[str, Any]:
2323
def _parse_response(
2424
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
2525
) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]:
26-
if response.status_code == HTTPStatus.OK:
26+
if response.status_code == 200:
2727
response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json())
2828

2929
return response_200

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
response_200 = response.text
2323
return response_200
2424
if client.raise_on_unexpected_status:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
return None
2323
if client.raise_on_unexpected_status:
2424
raise errors.UnexpectedStatus(response.status_code, response.content)

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
@@ -33,10 +33,10 @@ def _get_kwargs(
3333
def _parse_response(
3434
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
3535
) -> Optional[Union[Any, HTTPValidationError]]:
36-
if response.status_code == HTTPStatus.OK:
36+
if response.status_code == 200:
3737
response_200 = response.json()
3838
return response_200
39-
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
39+
if response.status_code == 422:
4040
response_422 = HTTPValidationError.from_dict(response.json())
4141

4242
return response_422

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
return None
2323
if client.raise_on_unexpected_status:
2424
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[bool]]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
response_200 = cast(List[bool], response.json())
2323

2424
return response_200

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[float]]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
response_200 = cast(List[float], response.json())
2323

2424
return response_200

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[int]]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
response_200 = cast(List[int], response.json())
2323

2424
return response_200

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[str]]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
response_200 = cast(List[str], response.json())
2323

2424
return response_200

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _get_kwargs(
6666
def _parse_response(
6767
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
6868
) -> Optional[Union[HTTPValidationError, List["AModel"]]]:
69-
if response.status_code == HTTPStatus.OK:
69+
if response.status_code == 200:
7070
response_200 = []
7171
_response_200 = response.json()
7272
for response_200_item_data in _response_200:
@@ -75,11 +75,11 @@ def _parse_response(
7575
response_200.append(response_200_item)
7676

7777
return response_200
78-
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
78+
if response.status_code == 422:
7979
response_422 = HTTPValidationError.from_dict(response.json())
8080

8181
return response_422
82-
if response.status_code == HTTPStatus.LOCKED:
82+
if response.status_code == 423:
8383
response_423 = HTTPValidationError.from_dict(response.json())
8484

8585
return response_423

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
@@ -33,10 +33,10 @@ def _get_kwargs(
3333
def _parse_response(
3434
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
3535
) -> Optional[Union[Any, HTTPValidationError]]:
36-
if response.status_code == HTTPStatus.OK:
36+
if response.status_code == 200:
3737
response_200 = response.json()
3838
return response_200
39-
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
39+
if response.status_code == 422:
4040
response_422 = HTTPValidationError.from_dict(response.json())
4141

4242
return response_422

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _get_kwargs() -> Dict[str, Any]:
1818

1919

2020
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
21-
if response.status_code == HTTPStatus.OK:
21+
if response.status_code == 200:
2222
return None
2323
if client.raise_on_unexpected_status:
2424
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _get_kwargs() -> Dict[str, Any]:
1919

2020

2121
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[File]:
22-
if response.status_code == HTTPStatus.OK:
22+
if response.status_code == 200:
2323
response_200 = File(payload=BytesIO(response.content))
2424

2525
return response_200

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def _get_kwargs(
3232
def _parse_response(
3333
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
3434
) -> Optional[Union[HTTPValidationError, str]]:
35-
if response.status_code == HTTPStatus.OK:
35+
if response.status_code == 200:
3636
response_200 = cast(str, response.json())
3737
return response_200
38-
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
38+
if response.status_code == 422:
3939
response_422 = HTTPValidationError.from_dict(response.json())
4040

4141
return response_422

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _get_kwargs(
3030

3131

3232
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
33-
if response.status_code == HTTPStatus.OK:
33+
if response.status_code == 200:
3434
return None
3535
if client.raise_on_unexpected_status:
3636
raise errors.UnexpectedStatus(response.status_code, response.content)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _get_kwargs(
3030

3131

3232
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
33-
if response.status_code == HTTPStatus.OK:
33+
if response.status_code == 200:
3434
return None
3535
if client.raise_on_unexpected_status:
3636
raise errors.UnexpectedStatus(response.status_code, response.content)

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
@@ -32,10 +32,10 @@ def _get_kwargs(
3232
def _parse_response(
3333
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
3434
) -> Optional[Union[HTTPValidationError, str]]:
35-
if response.status_code == HTTPStatus.OK:
35+
if response.status_code == 200:
3636
response_200 = cast(str, response.json())
3737
return response_200
38-
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
38+
if response.status_code == 422:
3939
response_422 = HTTPValidationError.from_dict(response.json())
4040

4141
return response_422

0 commit comments

Comments
 (0)