Conversation
Add direct iteration support to sandbox and snapshot page objects. This iterates only the items already loaded on that page. Leave iter_items() behavior unchanged for now so cross-page iteration still uses the existing explicit API.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds direct iteration support to sandbox/snapshot page objects so callers can iterate over only the items already loaded in the current page, while leaving cross-page iteration behavior on iter_items() unchanged.
Changes:
- Implement
__iter__/__aiter__onSandboxPage/AsyncSandboxPageandSnapshotPage/AsyncSnapshotPageto iterate only the current page’s items. - Extend unit tests to assert the new direct-iteration behavior for snapshot pages.
- Update the sandbox listing example to demonstrate direct iteration over the first async page.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/vercel/sandbox/page.py |
Adds direct iteration methods on page objects (sync + async) that yield only currently-loaded items. |
tests/unit/test_sandbox_page.py |
Adds assertions verifying direct iteration for snapshot page types (sync + async). |
examples/sandbox_15_list.py |
Demonstrates iterating items directly from the first async page before using pager-wide iteration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def __iter__(self) -> Iterator[SandboxModel]: | ||
| return iter(self.sandboxes) | ||
|
|
There was a problem hiding this comment.
Direct iteration was added for SandboxPage/AsyncSandboxPage here, but the PR’s tests only assert this behavior for SnapshotPage/AsyncSnapshotPage. Please add coverage that iterating a sandbox page (for sandbox in page / async for sandbox in page) yields only the already-loaded items and does not fetch subsequent pages (to guard against future regressions and to match the PR’s stated semantics).
| return self._controller.iter_items_sync(self) | ||
|
|
||
| def __iter__(self) -> Iterator[SandboxModel]: | ||
| return iter(self.sandboxes) |
There was a problem hiding this comment.
I'm confused. iter_items supposed to do the same that __iter__ you add but implementation is different? Why?
Also can we drop iter_items()? The name is very bad, in Python std lib it's reserved for iterating over key/values, here we're iterating over just values. This is bad api.
Add direct iteration support to sandbox and snapshot page objects. This iterates only the items already loaded on that page. Leave iter_items() behavior unchanged for now so cross-page iteration still uses the existing explicit API.