Skip to content

Commit fd0e690

Browse files
committed
revert rename of *_httpx_client methods to _httpx2_client
1 parent 3d0f248 commit fd0e690

81 files changed

Lines changed: 269 additions & 273 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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@
22
default: major
33
---
44

5-
# Default to using httpx2 instead of httpx causing the following breaking API changes:
6-
- `set_httpx_client` -> `set_httpx2_client`
7-
- `get_httpx_client` -> `get_httpx2_client`
8-
- `set_async_httpx_client` -> `set_async_httpx2_client`
9-
- `get_async_httpx_client` -> `get_async_httpx2_client`
5+
# Default to using httpx2 and drop support for httpx entirely

‎end_to_end_tests/functional_tests/generated_code_execution/test_path_parameters.py‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ 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_httpx2_client = MagicMock(spec=httpx2.Client)
47+
mock_httpx_client = MagicMock(spec=httpx2.Client)
4848
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_httpx2_client.request.return_value = mock_response
53+
mock_httpx_client.request.return_value = mock_response
5454

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

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

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

6767
# Normal characters should remain unchanged
6868
expected_url = "/items/item123/details/detail456"
@@ -71,17 +71,17 @@ def test_path_params_with_normal_chars_work(self, sync_detailed, Client):
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"""
7373
# Create a mock httpx2 client
74-
mock_httpx2_client = MagicMock(spec=httpx2.Client)
74+
mock_httpx_client = MagicMock(spec=httpx2.Client)
7575
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_httpx2_client.request.return_value = mock_response
80+
mock_httpx_client.request.return_value = mock_response
8181

8282
# Create a client with the mock httpx2 client
8383
client = Client(base_url="https://api.example.com")
84-
client.set_httpx2_client(mock_httpx2_client)
84+
client.set_httpx_client(mock_httpx_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_httpx2_client.request.assert_called_once()
95-
call_kwargs = mock_httpx2_client.request.call_args[1]
94+
mock_httpx_client.request.assert_called_once()
95+
call_kwargs = mock_httpx_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_httpx2_client = MagicMock(spec=httpx2.Client)
103+
mock_httpx_client = MagicMock(spec=httpx2.Client)
104104
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_httpx2_client.request.return_value = mock_response
109+
mock_httpx_client.request.return_value = mock_response
110110

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

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

120-
mock_httpx2_client.request.assert_called_once()
121-
call_kwargs = mock_httpx2_client.request.call_args[1]
120+
mock_httpx_client.request.assert_called_once()
121+
call_kwargs = mock_httpx_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_httpx2_client = MagicMock(spec=httpx2.Client)
129+
mock_httpx_client = MagicMock(spec=httpx2.Client)
130130
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_httpx2_client.request.return_value = mock_response
135+
mock_httpx_client.request.return_value = mock_response
136136

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

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

146-
mock_httpx2_client.request.assert_called_once()
147-
call_kwargs = mock_httpx2_client.request.call_args[1]
146+
mock_httpx_client.request.assert_called_once()
147+
call_kwargs = mock_httpx_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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ client = Client(
9393
httpx2_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
9494
)
9595

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

9999
You can even set the httpx2 client directly, but beware that this will override any existing settings (e.g., base_url):
@@ -106,7 +106,7 @@ 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_httpx2_client(httpx2.Client(base_url="https://api.example.com", proxy="http://localhost:8030"))
109+
client.set_httpx_client(httpx2.Client(base_url="https://api.example.com", proxy="http://localhost:8030"))
110110
```
111111

112112
## Building / publishing this package

‎end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/client.py‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ def with_timeout(self, timeout: httpx2.Timeout) -> "Client":
6565
self._async_client.timeout = timeout
6666
return evolve(self, timeout=timeout)
6767

68-
def set_httpx2_client(self, client: httpx2.Client) -> Self:
68+
def set_httpx_client(self, client: httpx2.Client) -> Self:
6969
"""Manually set the underlying httpx2.Client
7070
7171
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
7272
"""
7373
self._client = client
7474
return self
7575

76-
def get_httpx2_client(self) -> httpx2.Client:
76+
def get_httpx_client(self) -> httpx2.Client:
7777
"""Get the underlying httpx2.Client, constructing a new one if not previously set"""
7878
if self._client is None:
7979
self._client = httpx2.Client(
@@ -89,22 +89,22 @@ def get_httpx2_client(self) -> httpx2.Client:
8989

9090
def __enter__(self) -> Self:
9191
"""Enter a context manager for self.client—you cannot enter twice (see httpx2 docs)"""
92-
self.get_httpx2_client().__enter__()
92+
self.get_httpx_client().__enter__()
9393
return self
9494

9595
def __exit__(self, *args: Any, **kwargs: Any) -> None:
9696
"""Exit a context manager for internal httpx2.Client (see httpx2 docs)"""
97-
self.get_httpx2_client().__exit__(*args, **kwargs)
97+
self.get_httpx_client().__exit__(*args, **kwargs)
9898

99-
def set_async_httpx2_client(self, async_client: httpx2.AsyncClient) -> Self:
99+
def set_async_httpx_client(self, async_client: httpx2.AsyncClient) -> Self:
100100
"""Manually set the underlying httpx2.AsyncClient
101101
102102
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
103103
"""
104104
self._async_client = async_client
105105
return self
106106

107-
def get_async_httpx2_client(self) -> httpx2.AsyncClient:
107+
def get_async_httpx_client(self) -> httpx2.AsyncClient:
108108
"""Get the underlying httpx2.AsyncClient, constructing a new one if not previously set"""
109109
if self._async_client is None:
110110
self._async_client = httpx2.AsyncClient(
@@ -120,12 +120,12 @@ def get_async_httpx2_client(self) -> httpx2.AsyncClient:
120120

121121
async def __aenter__(self) -> Self:
122122
"""Enter a context manager for underlying httpx2.AsyncClient—you cannot enter twice (see httpx2 docs)"""
123-
await self.get_async_httpx2_client().__aenter__()
123+
await self.get_async_httpx_client().__aenter__()
124124
return self
125125

126126
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
127127
"""Exit a context manager for underlying httpx2.AsyncClient (see httpx2 docs)"""
128-
await self.get_async_httpx2_client().__aexit__(*args, **kwargs)
128+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
129129

130130

131131
@define
@@ -195,15 +195,15 @@ def with_timeout(self, timeout: httpx2.Timeout) -> "AuthenticatedClient":
195195
self._async_client.timeout = timeout
196196
return evolve(self, timeout=timeout)
197197

198-
def set_httpx2_client(self, client: httpx2.Client) -> Self:
198+
def set_httpx_client(self, client: httpx2.Client) -> Self:
199199
"""Manually set the underlying httpx2.Client
200200
201201
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
202202
"""
203203
self._client = client
204204
return self
205205

206-
def get_httpx2_client(self) -> httpx2.Client:
206+
def get_httpx_client(self) -> httpx2.Client:
207207
"""Get the underlying httpx2.Client, constructing a new one if not previously set"""
208208
if self._client is None:
209209
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
@@ -220,22 +220,22 @@ def get_httpx2_client(self) -> httpx2.Client:
220220

221221
def __enter__(self) -> Self:
222222
"""Enter a context manager for self.client—you cannot enter twice (see httpx2 docs)"""
223-
self.get_httpx2_client().__enter__()
223+
self.get_httpx_client().__enter__()
224224
return self
225225

226226
def __exit__(self, *args: Any, **kwargs: Any) -> None:
227227
"""Exit a context manager for internal httpx2.Client (see httpx2 docs)"""
228-
self.get_httpx2_client().__exit__(*args, **kwargs)
228+
self.get_httpx_client().__exit__(*args, **kwargs)
229229

230-
def set_async_httpx2_client(self, async_client: httpx2.AsyncClient) -> Self:
230+
def set_async_httpx_client(self, async_client: httpx2.AsyncClient) -> Self:
231231
"""Manually set the underlying httpx2.AsyncClient
232232
233233
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
234234
"""
235235
self._async_client = async_client
236236
return self
237237

238-
def get_async_httpx2_client(self) -> httpx2.AsyncClient:
238+
def get_async_httpx_client(self) -> httpx2.AsyncClient:
239239
"""Get the underlying httpx2.AsyncClient, constructing a new one if not previously set"""
240240
if self._async_client is None:
241241
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
@@ -252,9 +252,9 @@ def get_async_httpx2_client(self) -> httpx2.AsyncClient:
252252

253253
async def __aenter__(self) -> Self:
254254
"""Enter a context manager for underlying httpx2.AsyncClient—you cannot enter twice (see httpx2 docs)"""
255-
await self.get_async_httpx2_client().__aenter__()
255+
await self.get_async_httpx_client().__aenter__()
256256
return self
257257

258258
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
259259
"""Exit a context manager for underlying httpx2.AsyncClient (see httpx2 docs)"""
260-
await self.get_async_httpx2_client().__aexit__(*args, **kwargs)
260+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)

‎end_to_end_tests/golden-records/escapes-client/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ client = Client(
9393
httpx2_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
9494
)
9595

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

9999
You can even set the httpx2 client directly, but beware that this will override any existing settings (e.g., base_url):
@@ -106,7 +106,7 @@ 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_httpx2_client(httpx2.Client(base_url="https://api.example.com", proxy="http://localhost:8030"))
109+
client.set_httpx_client(httpx2.Client(base_url="https://api.example.com", proxy="http://localhost:8030"))
110110
```
111111

112112
## Building / publishing this package

‎end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/get_weird_responses.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def sync_detailed(
4949

5050
kwargs = _get_kwargs()
5151

52-
response = client.get_httpx2_client().request(
52+
response = client.get_httpx_client().request(
5353
**kwargs,
5454
)
5555

@@ -71,6 +71,6 @@ async def asyncio_detailed(
7171

7272
kwargs = _get_kwargs()
7373

74-
response = await client.get_async_httpx2_client().request(**kwargs)
74+
response = await client.get_async_httpx_client().request(**kwargs)
7575

7676
return _build_response(client=client, response=response)

‎end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/misc_metadata_escapes.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def sync_detailed(
6969
body=body,
7070
)
7171

72-
response = client.get_httpx2_client().request(
72+
response = client.get_httpx_client().request(
7373
**kwargs,
7474
)
7575

@@ -120,7 +120,7 @@ async def asyncio_detailed(
120120
body=body,
121121
)
122122

123-
response = await client.get_async_httpx2_client().request(**kwargs)
123+
response = await client.get_async_httpx_client().request(**kwargs)
124124

125125
return _build_response(client=client, response=response)
126126

‎end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/non_string_example.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def sync_detailed(
6868
body=body,
6969
)
7070

71-
response = client.get_httpx2_client().request(
71+
response = client.get_httpx_client().request(
7272
**kwargs,
7373
)
7474

@@ -96,6 +96,6 @@ async def asyncio_detailed(
9696
body=body,
9797
)
9898

99-
response = await client.get_async_httpx2_client().request(**kwargs)
99+
response = await client.get_async_httpx_client().request(**kwargs)
100100

101101
return _build_response(client=client, response=response)

‎end_to_end_tests/golden-records/escapes-client/escapes_client/api/default/property_escapes.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def sync_detailed(
6868
body=body,
6969
)
7070

71-
response = client.get_httpx2_client().request(
71+
response = client.get_httpx_client().request(
7272
**kwargs,
7373
)
7474

@@ -96,6 +96,6 @@ async def asyncio_detailed(
9696
body=body,
9797
)
9898

99-
response = await client.get_async_httpx2_client().request(**kwargs)
99+
response = await client.get_async_httpx_client().request(**kwargs)
100100

101101
return _build_response(client=client, response=response)

‎end_to_end_tests/golden-records/escapes-client/escapes_client/api/printtag_escape/with_braces_path.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def sync_detailed(
8989
printescape_param_name=printescape_param_name,
9090
)
9191

92-
response = client.get_httpx2_client().request(
92+
response = client.get_httpx_client().request(
9393
**kwargs,
9494
)
9595

@@ -126,6 +126,6 @@ async def asyncio_detailed(
126126
printescape_param_name=printescape_param_name,
127127
)
128128

129-
response = await client.get_async_httpx2_client().request(**kwargs)
129+
response = await client.get_async_httpx_client().request(**kwargs)
130130

131131
return _build_response(client=client, response=response)

0 commit comments

Comments
 (0)