Skip to content

Commit cf8c172

Browse files
committed
default to httpx2, skip pdm lock update
new file: .changeset/default_to_httpx2.md modified: end_to_end_tests/functional_tests/generated_code_execution/test_path_parameters.py modified: end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/README.md modified: end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/client.py modified: end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/types.py modified: end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/pyproject.toml modified: end_to_end_tests/golden-records/escapes-client/README.md modified: end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/get_weird_responses.py modified: end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/misc_metadata_escapes.py modified: end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/non_string_example.py modified: end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/property_escapes.py modified: end_to_end_tests/golden-records/escapes-client/escapes_client/api/printtag_escape/with_braces_path.py modified: end_to_end_tests/golden-records/escapes-client/escapes_client/client.py modified: end_to_end_tests/golden-records/escapes-client/escapes_client/types.py modified: end_to_end_tests/golden-records/escapes-client/pyproject.toml modified: end_to_end_tests/golden-records/my-enum-api-client/README.md modified: end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py modified: end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py modified: end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/api/tests/get_user_list.py modified: end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/api/tests/post_user_list.py modified: end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/client.py modified: end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/types.py modified: end_to_end_tests/golden-records/my-enum-api-client/pyproject.toml modified: end_to_end_tests/golden-records/my-test-api-client/README.md modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/bodies/json_like.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/bodies/optional_body.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/bodies/post_bodies_multiple.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/bodies/refs.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/config/content_type_override.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/default/get_common_parameters.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/default/get_models_allof.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/default/get_models_oneof_with_required_const.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/default/post_common_parameters.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/default/post_types_unions_duplicate_types.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/default/reserved_parameters.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/defaults/defaults_tests_defaults_post.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/location/get_location_header_types.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/location/get_location_query_optionality.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/naming/hyphen_in_path.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/naming/mixed_case.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/parameters/multiple_path_parameters.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/responses/default_status_code.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/responses/reference_response.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/responses/status_code_patterns.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/responses/status_code_precedence.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/responses/text_response.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tag1/get_tag_with_number.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tag2/get_tag_with_number.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/callback_test.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/description_with_backslash.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/get_basic_list_of_booleans.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/get_basic_list_of_floats.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/get_basic_list_of_integers.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/get_basic_list_of_strings.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/get_user_list.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/json_body_tests_json_body_post.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/no_response_tests_no_response_get.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/post_form_data.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/post_form_data_inline.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/post_tests_json_body_string.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/test_inline_objects.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/tests/upload_file_tests_upload_post.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/api/true_/false_.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/client.py modified: end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/types.py modified: end_to_end_tests/golden-records/my-test-api-client/pyproject.toml modified: end_to_end_tests/golden-records/test-3-1-features-client/README.md modified: end_to_end_tests/golden-records/test-3-1-features-client/pyproject.toml modified: end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/api/const/post_const_path.py modified: end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/api/prefix_items/post_prefix_items.py modified: end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/client.py modified: end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/types.py modified: end_to_end_tests/metadata_snapshots/pdm.pyproject.toml modified: end_to_end_tests/metadata_snapshots/poetry.pyproject.toml modified: end_to_end_tests/metadata_snapshots/setup.py modified: end_to_end_tests/metadata_snapshots/uv.pyproject.toml modified: integration-tests/README.md modified: integration-tests/integration_tests/api/body/post_body_multipart.py modified: integration-tests/integration_tests/api/parameters/post_parameters_header.py modified: integration-tests/integration_tests/client.py modified: integration-tests/integration_tests/types.py modified: integration-tests/pyproject.toml modified: integration-tests/tests/test_api/test_body/test_post_body_multipart.py modified: openapi_python_client/__init__.py modified: openapi_python_client/parser/responses.py modified: openapi_python_client/templates/README.md.jinja modified: openapi_python_client/templates/client.py.jinja modified: openapi_python_client/templates/endpoint_macros.py.jinja modified: openapi_python_client/templates/endpoint_module.py.jinja modified: openapi_python_client/templates/pyproject_pdm.toml.jinja modified: openapi_python_client/templates/pyproject_poetry.toml.jinja modified: openapi_python_client/templates/pyproject_uv.toml.jinja modified: openapi_python_client/templates/setup.py.jinja modified: openapi_python_client/templates/types.py.jinja modified: pyproject.toml
1 parent 4a2f3db commit cf8c172

107 files changed

Lines changed: 1011 additions & 1006 deletions

File tree

Some content is hidden

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

‎.changeset/default_to_httpx2.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: major
3+
---
4+
5+
# Default to using httpx2

‎end_to_end_tests/functional_tests/generated_code_execution/test_path_parameters.py‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest.mock import MagicMock
22

3-
import httpx
3+
import httpx2
44

55
from end_to_end_tests.functional_tests.helpers import (
66
with_generated_client_fixture,
@@ -44,44 +44,44 @@ class TestPathParameterEncoding:
4444

4545
def test_path_params_with_normal_chars_work(self, sync_detailed, Client):
4646
"""Test that normal alphanumeric path parameters still work correctly"""
47-
mock_httpx_client = MagicMock(spec=httpx.Client)
48-
mock_response = MagicMock(spec=httpx.Response)
47+
mock_httpx2_client = MagicMock(spec=httpx2.Client)
48+
mock_response = MagicMock(spec=httpx2.Response)
4949
mock_response.status_code = 200
5050
mock_response.json.return_value = {"id": "test"}
5151
mock_response.content = b'{"id": "test"}'
5252
mock_response.headers = {}
53-
mock_httpx_client.request.return_value = mock_response
53+
mock_httpx2_client.request.return_value = mock_response
5454

5555
client = Client(base_url="https://api.example.com")
56-
client.set_httpx_client(mock_httpx_client)
56+
client.set_httpx2_client(mock_httpx2_client)
5757

5858
sync_detailed(
5959
item_id="item123",
6060
detail_id="detail456",
6161
client=client,
6262
)
6363

64-
mock_httpx_client.request.assert_called_once()
65-
call_kwargs = mock_httpx_client.request.call_args[1]
64+
mock_httpx2_client.request.assert_called_once()
65+
call_kwargs = mock_httpx2_client.request.call_args[1]
6666

6767
# Normal characters should remain unchanged
6868
expected_url = "/items/item123/details/detail456"
6969
assert call_kwargs["url"] == expected_url
7070

7171
def test_path_params_with_reserved_chars_are_encoded(self, sync_detailed, Client):
7272
"""Test that path parameters with reserved characters are properly URL-encoded"""
73-
# Create a mock httpx client
74-
mock_httpx_client = MagicMock(spec=httpx.Client)
75-
mock_response = MagicMock(spec=httpx.Response)
73+
# Create a mock httpx2 client
74+
mock_httpx2_client = MagicMock(spec=httpx2.Client)
75+
mock_response = MagicMock(spec=httpx2.Response)
7676
mock_response.status_code = 200
7777
mock_response.json.return_value = {"id": "test"}
7878
mock_response.content = b'{"id": "test"}'
7979
mock_response.headers = {}
80-
mock_httpx_client.request.return_value = mock_response
80+
mock_httpx2_client.request.return_value = mock_response
8181

82-
# Create a client with the mock httpx client
82+
# Create a client with the mock httpx2 client
8383
client = Client(base_url="https://api.example.com")
84-
client.set_httpx_client(mock_httpx_client)
84+
client.set_httpx2_client(mock_httpx2_client)
8585

8686
# Call the endpoint with path parameters containing reserved characters
8787
sync_detailed(
@@ -91,60 +91,60 @@ def test_path_params_with_reserved_chars_are_encoded(self, sync_detailed, Client
9191
)
9292

9393
# Verify the request was made with properly encoded URL
94-
mock_httpx_client.request.assert_called_once()
95-
call_kwargs = mock_httpx_client.request.call_args[1]
94+
mock_httpx2_client.request.assert_called_once()
95+
call_kwargs = mock_httpx2_client.request.call_args[1]
9696

9797
# The URL should have encoded slashes and query characters
9898
expected_url = "/items/item%2Fwith%2Fslashes/details/detail%3Fwith%3Dquery%26chars"
9999
assert call_kwargs["url"] == expected_url
100100

101101
def test_path_params_with_spaces_are_encoded(self, sync_detailed, Client):
102102
"""Test that path parameters with spaces are properly URL-encoded"""
103-
mock_httpx_client = MagicMock(spec=httpx.Client)
104-
mock_response = MagicMock(spec=httpx.Response)
103+
mock_httpx2_client = MagicMock(spec=httpx2.Client)
104+
mock_response = MagicMock(spec=httpx2.Response)
105105
mock_response.status_code = 200
106106
mock_response.json.return_value = {"id": "test"}
107107
mock_response.content = b'{"id": "test"}'
108108
mock_response.headers = {}
109-
mock_httpx_client.request.return_value = mock_response
109+
mock_httpx2_client.request.return_value = mock_response
110110

111111
client = Client(base_url="https://api.example.com")
112-
client.set_httpx_client(mock_httpx_client)
112+
client.set_httpx2_client(mock_httpx2_client)
113113

114114
sync_detailed(
115115
item_id="item with spaces",
116116
detail_id="detail with spaces",
117117
client=client,
118118
)
119119

120-
mock_httpx_client.request.assert_called_once()
121-
call_kwargs = mock_httpx_client.request.call_args[1]
120+
mock_httpx2_client.request.assert_called_once()
121+
call_kwargs = mock_httpx2_client.request.call_args[1]
122122

123123
# Spaces should be encoded as %20
124124
expected_url = "/items/item%20with%20spaces/details/detail%20with%20spaces"
125125
assert call_kwargs["url"] == expected_url
126126

127127
def test_path_params_with_hash_are_encoded(self, sync_detailed, Client):
128128
"""Test that path parameters with hash/fragment characters are properly URL-encoded"""
129-
mock_httpx_client = MagicMock(spec=httpx.Client)
130-
mock_response = MagicMock(spec=httpx.Response)
129+
mock_httpx2_client = MagicMock(spec=httpx2.Client)
130+
mock_response = MagicMock(spec=httpx2.Response)
131131
mock_response.status_code = 200
132132
mock_response.json.return_value = {"id": "test"}
133133
mock_response.content = b'{"id": "test"}'
134134
mock_response.headers = {}
135-
mock_httpx_client.request.return_value = mock_response
135+
mock_httpx2_client.request.return_value = mock_response
136136

137137
client = Client(base_url="https://api.example.com")
138-
client.set_httpx_client(mock_httpx_client)
138+
client.set_httpx2_client(mock_httpx2_client)
139139

140140
sync_detailed(
141141
item_id="item#1",
142142
detail_id="detail#id",
143143
client=client,
144144
)
145145

146-
mock_httpx_client.request.assert_called_once()
147-
call_kwargs = mock_httpx_client.request.call_args[1]
146+
mock_httpx2_client.request.assert_called_once()
147+
call_kwargs = mock_httpx2_client.request.call_args[1]
148148

149149
# Hash should be encoded as %23
150150
expected_url = "/items/item%231/details/detail%23id"

‎end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Things to know:
7676

7777
## Advanced customizations
7878

79-
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
79+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx2.Client` or `httpx2.AsyncClient` (depending on your use-case):
8080

8181
```python
8282
from my_test_api_client import Client
@@ -90,23 +90,23 @@ def log_response(response):
9090

9191
client = Client(
9292
base_url="https://api.example.com",
93-
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
93+
httpx2_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
9494
)
9595

96-
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
96+
# Or get the underlying httpx2 client to modify directly with client.get_httpx2_client() or client.get_async_httpx2_client()
9797
```
9898

99-
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
99+
You can even set the httpx2 client directly, but beware that this will override any existing settings (e.g., base_url):
100100

101101
```python
102-
import httpx
102+
import httpx2
103103
from my_test_api_client import Client
104104

105105
client = Client(
106106
base_url="https://api.example.com",
107107
)
108108
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
109-
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
109+
client.set_httpx2_client(httpx2.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
110110
```
111111

112112
## Building / publishing this package

0 commit comments

Comments
 (0)