Expose max_items on Python paginated list methods
Closes the last Python parity gap on pagination control: every other SDK exposes a public cap on auto-pagination (maxItems in TypeScript/Kotlin/Swift, ListOptions.Limit in Go), but Python's cap died at the private _request_paginated plumbing — external developers had no way to stop a 10,000-page collection early.
What changed
- Generator (
python/scripts/generate_services.py): every paginated operation now emits a keyword-onlymax_items: int | None = Noneand threads it into the base paginators. Regen touched all 36 service modules — uniformly additive (122 signature additions + 122 call-site threadings across sync and async, remainder is ruff line-wrap of those same signatures; no other content changed, no types.py/metadata.json churn). - Base paginators (
_base.py/_async_base.py, the sanctioned hand-written exceptions undergenerated/): the key and wrapped families now acceptmax_itemswith the same exact-boundarytruncatedsemantics the plain family already had (SPEC steps 4a/6g) —truncatedonly when items were dropped or a next Link was left unfetched; a cap landing exactly on the final item of a Link-less last page is complete, not truncated. Collection stops as soon as the cap is met, without fetching further pages. - Conformance runner: the two
maxItemsskips are removed andconfigOverrides.maxItemsis wired through theListProjectsdispatch (mirroring the Kotlin runner). - SPEC §Zero-Skip roster: the two Python lines are deleted — exactly its own lines, per the roster contract. Ruby's waiver-backed (2C.4) lines remain.
- Tests:
python/tests/test_max_items_public.py— 12 cases covering plain (projects.list), key (_paginate_key; no generated operation uses this family publicly), and wrapped (reports.person_progress) in sync and async, including early-stop-with-drop and exact-boundary-not-truncated. - Docs:
python/README.mdpagination section documentsmax_itemsand the truncation contract (wording aligned with the Kotlin README).
Red proofs
Conformance, skips removed, against the pristine SDK:
FAIL: maxItems caps results across pages
Expected >= 2 requests, got 0; Expected no error, got: TypeError: ProjectsService.list() got an unexpected keyword argument 'max_items'; Expected responseMeta.truncated = True, got None
FAIL: maxItems landing exactly on the final item is not truncated
Expected >= 2 requests, got 0; Expected no error, got: TypeError: ProjectsService.list() got an unexpected keyword argument 'max_items'; Expected responseMeta.truncated = False, got None
Results: 120 passed, 2 failed, 2 skipped
REAL_EXIT=2
New unit tests against the pristine SDK (base files + generated services swapped back to origin/main via git show): all 12 fail —
FAILED tests/test_max_items_public.py::TestPlainListMaxItems::test_cap_stops_pagination_early_and_truncates
FAILED tests/test_max_items_public.py::TestPlainListMaxItems::test_cap_on_exact_final_item_is_not_truncated
FAILED tests/test_max_items_public.py::TestAsyncPlainListMaxItems::test_cap_stops_pagination_early_and_truncates
FAILED tests/test_max_items_public.py::TestAsyncPlainListMaxItems::test_cap_on_exact_final_item_is_not_truncated
FAILED tests/test_max_items_public.py::TestKeyPaginateMaxItems::test_cap_drops_items_and_stops_before_next_page
FAILED tests/test_max_items_public.py::TestKeyPaginateMaxItems::test_cap_on_exact_final_item_is_not_truncated
FAILED tests/test_max_items_public.py::TestAsyncKeyPaginateMaxItems::test_cap_drops_items_and_stops_before_next_page
FAILED tests/test_max_items_public.py::TestAsyncKeyPaginateMaxItems::test_cap_on_exact_final_item_is_not_truncated
FAILED tests/test_max_items_public.py::TestWrappedMaxItems::test_cap_met_on_first_page_stops_before_next_page
FAILED tests/test_max_items_public.py::TestWrappedMaxItems::test_cap_on_exact_final_item_is_not_truncated
FAILED tests/test_max_items_public.py::TestAsyncWrappedMaxItems::test_cap_met_on_first_page_stops_before_next_page
FAILED tests/test_max_items_public.py::TestAsyncWrappedMaxItems::test_cap_on_exact_final_item_is_not_truncated
12 failed in 2.88s
REAL_EXIT=1
Green
make conformance-python:Results: 122 passed, 0 failed, 2 skipped(REAL_EXIT=0; remaining 2 are the rostered DownloadURL pair)make py-check(drift + tests + mypy + ruff):722 passed,REAL_EXIT=0
No wire-format change: max_items is a client-side collection cap, never sent as a query parameter. Additive keyword-only parameter — zero breakage for existing callers.
Summary by cubic
Adds max_items to all Python paginated list methods to cap auto-pagination and report accurate meta.truncated, matching other SDKs. Non‑positive caps are treated as no cap, and the two Python maxItems conformance skips are removed.
-
New Features
- Generator emits keyword-only
max_itemsfor every paginated operation (sync/async) and threads it into the base paginators. - Pagination honors the cap: stop before fetching more pages;
meta.truncatedis True only when items were dropped or a next Link was left unfetched (exact-boundary caps are not truncated). - Conformance runner passes
configOverrides.maxItemsthroughListProjects; SPEC roster lines removed; README updated; tests cover plain/key/wrapped paginators; Python conformance passes. - Backward-compatible: additive keyword-only arg; no wire-format change.
- Generator emits keyword-only
-
Bug Fixes
- Normalize non‑positive
max_items(<= 0) to “no cap,” matching other SDKs; tests pin the behavior.
- Normalize non‑positive