Skip to content

feat: add iter_pull_request_reviews helper for paginating PR review runs - #90

Open
Tyagiquamar wants to merge 1 commit into
prooflinedev:mainfrom
Tyagiquamar:feat/iter-pull-request-reviews
Open

Tyagiquamar wants to merge 1 commit into
prooflinedev:mainfrom
Tyagiquamar:feat/iter-pull-request-reviews

Conversation

@Tyagiquamar

Copy link
Copy Markdown

Summary

Add iter_pull_request_reviews iterator method to both ProoflineClient and AsyncProoflineClient, providing bounded cursor-based pagination over a specific pull request's review runs (/api/v1/organizations/{org_id}/reviews/pr/{repository}/{pull_request_number}).

Problem

The SDK provides iter_reviews to traverse organization-level latest reviews (/api/v1/organizations/{org_id}/reviews), but exposes only single-page retrieval (list_pull_request_reviews) for pull-request review history. When an engineering workflow inspects the historical progression of reviews on a given pull request across multiple runs or iterations, callers must write custom cursor tracking, cycle detection, and pagination bound loops.

Solution

  1. Added iter_pull_request_reviews to ProoflineClient returning Iterator[ReviewSummary].
  2. Added iter_pull_request_reviews to AsyncProoflineClient returning AsyncIterator[ReviewSummary].
  3. Standardized parameter handling with _page_limits, _next_cursor, and _pagination_limit, supporting page_size, max_pages, max_items, and optional filters.
  4. Registered iter_pull_request_reviews in scripts/contracts.py helper registry to maintain public contract validation.
  5. Added comprehensive test coverage in tests/test_http.py covering:
    • Path and query parameters (repository, pull_request_number, query filters)
    • Cursor preservation and forward paging
    • Cycle detection and non-advancing cursor rejection
    • Enforcement of max_pages and max_items bounds

Tests

Ran native test suite and linters locally:

  • pytest tests/test_http.py -k "test_iter_pull_request_reviews": 2 passed in 0.84s (sync and async).
  • pytest tests/test_exports.py: 14 passed.
  • ruff check .: All checks passed.
  • ruff format --check .: 237 files already formatted.
  • mypy proofline scripts: Success (no issues found in 228 source files).
  • python scripts/contracts.py: Python operation and outcome-vocabulary contracts passed.
  • Full pytest test suite (pytest -q): 221 passed, 8 subtests passed.

Risk

None. This is an additive convenience method that does not modify existing method signatures or REST models.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant