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
Lines changed: 13 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)

0 commit comments

Comments
 (0)