Skip to content

Commit ea506d7

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat: OpenAPI spec update via Stainless API (#89)
1 parent 792e1ec commit ea506d7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/cloudflare/_base_client.py

+10
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,11 @@ def __init__(
779779
else:
780780
timeout = DEFAULT_TIMEOUT
781781

782+
if http_client is not None and not isinstance(http_client, httpx.Client): # pyright: ignore[reportUnnecessaryIsInstance]
783+
raise TypeError(
784+
f"Invalid `http_client` argument; Expected an instance of `httpx.Client` but got {type(http_client)}"
785+
)
786+
782787
super().__init__(
783788
version=version,
784789
limits=limits,
@@ -1308,6 +1313,11 @@ def __init__(
13081313
else:
13091314
timeout = DEFAULT_TIMEOUT
13101315

1316+
if http_client is not None and not isinstance(http_client, httpx.AsyncClient): # pyright: ignore[reportUnnecessaryIsInstance]
1317+
raise TypeError(
1318+
f"Invalid `http_client` argument; Expected an instance of `httpx.AsyncClient` but got {type(http_client)}"
1319+
)
1320+
13111321
super().__init__(
13121322
version=version,
13131323
base_url=base_url,

tests/test_client.py

+22
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,17 @@ def test_http_client_timeout_option(self) -> None:
328328
timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
329329
assert timeout == DEFAULT_TIMEOUT # our default
330330

331+
async def test_invalid_http_client(self) -> None:
332+
with pytest.raises(TypeError, match="Invalid `http_client` arg"):
333+
async with httpx.AsyncClient() as http_client:
334+
Cloudflare(
335+
base_url=base_url,
336+
api_key=api_key,
337+
api_email=api_email,
338+
_strict_response_validation=True,
339+
http_client=cast(Any, http_client),
340+
)
341+
331342
def test_default_headers_option(self) -> None:
332343
client = Cloudflare(
333344
base_url=base_url,
@@ -1075,6 +1086,17 @@ async def test_http_client_timeout_option(self) -> None:
10751086
timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
10761087
assert timeout == DEFAULT_TIMEOUT # our default
10771088

1089+
def test_invalid_http_client(self) -> None:
1090+
with pytest.raises(TypeError, match="Invalid `http_client` arg"):
1091+
with httpx.Client() as http_client:
1092+
AsyncCloudflare(
1093+
base_url=base_url,
1094+
api_key=api_key,
1095+
api_email=api_email,
1096+
_strict_response_validation=True,
1097+
http_client=cast(Any, http_client),
1098+
)
1099+
10781100
def test_default_headers_option(self) -> None:
10791101
client = AsyncCloudflare(
10801102
base_url=base_url,

0 commit comments

Comments
 (0)