Skip to content

Commit d19970f

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#193)
1 parent 5d528fc commit d19970f

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,12 @@ response = client.post(
332332
print(response.headers.get("x-foo"))
333333
```
334334

335-
#### Undocumented params
335+
#### Undocumented request params
336336

337337
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
338338
options.
339339

340-
#### Undocumented properties
340+
#### Undocumented response properties
341341

342342
To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
343343
can also get all the extra fields on the Pydantic model as a dict with

src/cloudflare/_base_client.py

+5
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@ def __init__(
360360
self._strict_response_validation = _strict_response_validation
361361
self._idempotency_header = None
362362

363+
if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
364+
raise TypeError(
365+
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `cloudflare.DEFAULT_MAX_RETRIES`"
366+
)
367+
363368
def _enforce_trailing_slash(self, url: URL) -> URL:
364369
if url.raw_path.endswith(b"/"):
365370
return url

tests/test_client.py

+20
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,16 @@ class Model(BaseModel):
727727

728728
assert isinstance(exc.value.__cause__, ValidationError)
729729

730+
def test_client_max_retries_validation(self) -> None:
731+
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
732+
Cloudflare(
733+
base_url=base_url,
734+
api_key=api_key,
735+
api_email=api_email,
736+
_strict_response_validation=True,
737+
max_retries=cast(Any, None),
738+
)
739+
730740
@pytest.mark.respx(base_url=base_url)
731741
def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:
732742
class Model(BaseModel):
@@ -1493,6 +1503,16 @@ class Model(BaseModel):
14931503

14941504
assert isinstance(exc.value.__cause__, ValidationError)
14951505

1506+
async def test_client_max_retries_validation(self) -> None:
1507+
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
1508+
AsyncCloudflare(
1509+
base_url=base_url,
1510+
api_key=api_key,
1511+
api_email=api_email,
1512+
_strict_response_validation=True,
1513+
max_retries=cast(Any, None),
1514+
)
1515+
14961516
@pytest.mark.respx(base_url=base_url)
14971517
@pytest.mark.asyncio
14981518
async def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:

0 commit comments

Comments
 (0)