Skip to content

Commit e329453

Browse files
committed
Swap httpx2_args back to httpx_args to match set_httpx_client (and reduce breakage)
1 parent 7d4563f commit e329453

16 files changed

Lines changed: 62 additions & 60 deletions

File tree

‎.changeset/default_to_httpx2.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ default: major
55
# Switch from `httpx` to `httpx2` in generated clients
66

77
[`httpx2`](https://pydantic.dev/docs/httpx2/get-started/) is largely compatible with `httpx` and should only be a breaking change for users who customize the internal `Client`.
8+
9+
Thanks to @s-sajid-ali and @johnthagen for making this one happen in PR #1461 and discussion #1455!

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def log_response(response):
9090

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

9696
# Or get the underlying httpx2 client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Client:
2525
2626
``follow_redirects``: Whether or not to follow redirects. Default value is False.
2727
28-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
28+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
2929
3030
"""
3131

@@ -37,7 +37,7 @@ class Client:
3737
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
3838
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
3939
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
40-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
40+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
4141
_client: httpx2.Client | None = field(default=None, init=False)
4242
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
4343

@@ -83,7 +83,7 @@ def get_httpx_client(self) -> httpx2.Client:
8383
timeout=self._timeout,
8484
verify=self._verify_ssl,
8585
follow_redirects=self._follow_redirects,
86-
**self._httpx2_args,
86+
**self._httpx_args,
8787
)
8888
return self._client
8989

@@ -114,7 +114,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
114114
timeout=self._timeout,
115115
verify=self._verify_ssl,
116116
follow_redirects=self._follow_redirects,
117-
**self._httpx2_args,
117+
**self._httpx_args,
118118
)
119119
return self._async_client
120120

@@ -148,7 +148,7 @@ class AuthenticatedClient:
148148
149149
``follow_redirects``: Whether or not to follow redirects. Default value is False.
150150
151-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
151+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
152152
153153
"""
154154

@@ -160,7 +160,7 @@ class AuthenticatedClient:
160160
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
161161
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
162162
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
163-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
163+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
164164
_client: httpx2.Client | None = field(default=None, init=False)
165165
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
166166

@@ -214,7 +214,7 @@ def get_httpx_client(self) -> httpx2.Client:
214214
timeout=self._timeout,
215215
verify=self._verify_ssl,
216216
follow_redirects=self._follow_redirects,
217-
**self._httpx2_args,
217+
**self._httpx_args,
218218
)
219219
return self._client
220220

@@ -246,7 +246,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
246246
timeout=self._timeout,
247247
verify=self._verify_ssl,
248248
follow_redirects=self._follow_redirects,
249-
**self._httpx2_args,
249+
**self._httpx_args,
250250
)
251251
return self._async_client
252252

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def log_response(response):
9090

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

9696
# Or get the underlying httpx2 client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()

‎end_to_end_tests/golden-records/escapes-client/escapes_client/client.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Client:
2525
2626
``follow_redirects``: Whether or not to follow redirects. Default value is False.
2727
28-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
28+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
2929
3030
3131
Attributes:
@@ -41,7 +41,7 @@ class Client:
4141
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
4242
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
4343
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
44-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
44+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
4545
_client: httpx2.Client | None = field(default=None, init=False)
4646
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
4747

@@ -87,7 +87,7 @@ def get_httpx_client(self) -> httpx2.Client:
8787
timeout=self._timeout,
8888
verify=self._verify_ssl,
8989
follow_redirects=self._follow_redirects,
90-
**self._httpx2_args,
90+
**self._httpx_args,
9191
)
9292
return self._client
9393

@@ -118,7 +118,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
118118
timeout=self._timeout,
119119
verify=self._verify_ssl,
120120
follow_redirects=self._follow_redirects,
121-
**self._httpx2_args,
121+
**self._httpx_args,
122122
)
123123
return self._async_client
124124

@@ -152,7 +152,7 @@ class AuthenticatedClient:
152152
153153
``follow_redirects``: Whether or not to follow redirects. Default value is False.
154154
155-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
155+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
156156
157157
158158
Attributes:
@@ -171,7 +171,7 @@ class AuthenticatedClient:
171171
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
172172
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
173173
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
174-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
174+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
175175
_client: httpx2.Client | None = field(default=None, init=False)
176176
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
177177

@@ -222,7 +222,7 @@ def get_httpx_client(self) -> httpx2.Client:
222222
timeout=self._timeout,
223223
verify=self._verify_ssl,
224224
follow_redirects=self._follow_redirects,
225-
**self._httpx2_args,
225+
**self._httpx_args,
226226
)
227227
return self._client
228228

@@ -254,7 +254,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
254254
timeout=self._timeout,
255255
verify=self._verify_ssl,
256256
follow_redirects=self._follow_redirects,
257-
**self._httpx2_args,
257+
**self._httpx_args,
258258
)
259259
return self._async_client
260260

‎end_to_end_tests/golden-records/my-enum-api-client/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def log_response(response):
9090

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

9696
# Or get the underlying httpx2 client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()

‎end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/client.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Client:
2525
2626
``follow_redirects``: Whether or not to follow redirects. Default value is False.
2727
28-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
28+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
2929
3030
3131
Attributes:
@@ -41,7 +41,7 @@ class Client:
4141
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
4242
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
4343
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
44-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
44+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
4545
_client: httpx2.Client | None = field(default=None, init=False)
4646
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
4747

@@ -87,7 +87,7 @@ def get_httpx_client(self) -> httpx2.Client:
8787
timeout=self._timeout,
8888
verify=self._verify_ssl,
8989
follow_redirects=self._follow_redirects,
90-
**self._httpx2_args,
90+
**self._httpx_args,
9191
)
9292
return self._client
9393

@@ -118,7 +118,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
118118
timeout=self._timeout,
119119
verify=self._verify_ssl,
120120
follow_redirects=self._follow_redirects,
121-
**self._httpx2_args,
121+
**self._httpx_args,
122122
)
123123
return self._async_client
124124

@@ -152,7 +152,7 @@ class AuthenticatedClient:
152152
153153
``follow_redirects``: Whether or not to follow redirects. Default value is False.
154154
155-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
155+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
156156
157157
158158
Attributes:
@@ -171,7 +171,7 @@ class AuthenticatedClient:
171171
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
172172
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
173173
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
174-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
174+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
175175
_client: httpx2.Client | None = field(default=None, init=False)
176176
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
177177

@@ -222,7 +222,7 @@ def get_httpx_client(self) -> httpx2.Client:
222222
timeout=self._timeout,
223223
verify=self._verify_ssl,
224224
follow_redirects=self._follow_redirects,
225-
**self._httpx2_args,
225+
**self._httpx_args,
226226
)
227227
return self._client
228228

@@ -254,7 +254,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
254254
timeout=self._timeout,
255255
verify=self._verify_ssl,
256256
follow_redirects=self._follow_redirects,
257-
**self._httpx2_args,
257+
**self._httpx_args,
258258
)
259259
return self._async_client
260260

‎end_to_end_tests/golden-records/my-test-api-client/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def log_response(response):
9090

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

9696
# Or get the underlying httpx2 client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()

‎end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/client.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Client:
2525
2626
``follow_redirects``: Whether or not to follow redirects. Default value is False.
2727
28-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
28+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
2929
3030
3131
Attributes:
@@ -41,7 +41,7 @@ class Client:
4141
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
4242
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
4343
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
44-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
44+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
4545
_client: httpx2.Client | None = field(default=None, init=False)
4646
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
4747

@@ -87,7 +87,7 @@ def get_httpx_client(self) -> httpx2.Client:
8787
timeout=self._timeout,
8888
verify=self._verify_ssl,
8989
follow_redirects=self._follow_redirects,
90-
**self._httpx2_args,
90+
**self._httpx_args,
9191
)
9292
return self._client
9393

@@ -118,7 +118,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
118118
timeout=self._timeout,
119119
verify=self._verify_ssl,
120120
follow_redirects=self._follow_redirects,
121-
**self._httpx2_args,
121+
**self._httpx_args,
122122
)
123123
return self._async_client
124124

@@ -152,7 +152,7 @@ class AuthenticatedClient:
152152
153153
``follow_redirects``: Whether or not to follow redirects. Default value is False.
154154
155-
``httpx2_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
155+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx2.Client`` and ``httpx2.AsyncClient`` constructor.
156156
157157
158158
Attributes:
@@ -171,7 +171,7 @@ class AuthenticatedClient:
171171
_timeout: httpx2.Timeout | None = field(default=None, kw_only=True, alias="timeout")
172172
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
173173
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
174-
_httpx2_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx2_args")
174+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
175175
_client: httpx2.Client | None = field(default=None, init=False)
176176
_async_client: httpx2.AsyncClient | None = field(default=None, init=False)
177177

@@ -222,7 +222,7 @@ def get_httpx_client(self) -> httpx2.Client:
222222
timeout=self._timeout,
223223
verify=self._verify_ssl,
224224
follow_redirects=self._follow_redirects,
225-
**self._httpx2_args,
225+
**self._httpx_args,
226226
)
227227
return self._client
228228

@@ -254,7 +254,7 @@ def get_async_httpx_client(self) -> httpx2.AsyncClient:
254254
timeout=self._timeout,
255255
verify=self._verify_ssl,
256256
follow_redirects=self._follow_redirects,
257-
**self._httpx2_args,
257+
**self._httpx_args,
258258
)
259259
return self._async_client
260260

‎end_to_end_tests/golden-records/test-3-1-features-client/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def log_response(response):
9090

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

9696
# Or get the underlying httpx2 client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()

0 commit comments

Comments
 (0)