Skip to content

Add request_and_wait_for_review to sync and async clients - #50

Closed
EyerusalemGebremedhin wants to merge 3 commits into
prooflinedev:mainfrom
EyerusalemGebremedhin:feature/add-request-and-wait-for-review
Closed

EyerusalemGebremedhin wants to merge 3 commits into
prooflinedev:mainfrom
EyerusalemGebremedhin:feature/add-request-and-wait-for-review

Conversation

@EyerusalemGebremedhin

@EyerusalemGebremedhin EyerusalemGebremedhin commented Nov 15, 2026 •

Copy link
Copy Markdown

Problem

To get a finished review, SDK users have to call request_review(), take the review ID from the response, and pass it to wait_for_review(). This contribution adds a single method that does both steps.

Solution

Adds request_and_wait_for_review() to ProoflineClient and AsyncProoflineClient in proofline/client.py. It calls the existing request_review(), then the existing wait_for_review() with the returned review ID, and returns a ReviewOutcome. A refused request raises ProoflineError, and a timeout returns TIMED_OUT, as with wait_for_review(). The README gets a short usage example.

Invalid timeout fix

Proofline's review of my own copy of this branch flagged that a negative or non-finite timeout was only rejected after a review had already been requested (eyerusalem-sdk-lab#1). I reproduced it: with the fix removed, the new tests fail because the fake server receives an unexpected POST to the reviews path. The timeout is now validated before request_review() is called, in both the sync and async helpers, using the same check and message as wait_for_review(). Proofline marked that finding fixed.

Tests

10 test cases in tests/test_http.py, each running sync and async:

  • test_request_and_wait_for_review_returns_completed_outcome: POST to the reviews endpoint, then GET poll, returns a COMPLETED outcome with the review URL
  • test_request_and_wait_for_review_propagates_refusal: a refused request raises ProoflineError with status 409, and no GET poll is attempted
  • test_request_and_wait_for_review_timeout: the review never completes, returns TIMED_OUT with the last recorded review
  • test_request_and_wait_for_review_bad_timeout_raises_before_request: timeout=-1 raises ValueError, and no HTTP request is sent to the server
  • test_request_and_wait_for_review_bad_timeout_infinite_raises_before_request: timeout=float("inf") raises ValueError, and no HTTP request is sent to the server

Verification: uv run -m pytest -q -k request_and_wait_for_review → 10 passed. Full suite, Ruff lint, Ruff format check, and mypy all clean.

How to reproduce

  1. Clone https://github.com/EyerusalemGebremedhin/sdk-python and check out feature/add-request-and-wait-for-review.
  2. python -m pytest tests/test_http.py -k request_and_wait_for_review -v

Usage example

from proofline import ProoflineClient

with ProoflineClient() as client:
    outcome = client.request_and_wait_for_review(
        organization_id,
        repository_id,
        12,
        timeout=300,
    )
    print(outcome.status, outcome.review_url)

AI disclosure

I used an AI coding tool during this contribution. I asked it to suggest several different problems in this SDK and decided which one to take on: a single call that requests a review and waits for its result. I directed the implementation, reviewed the diff, and ran the tests myself. The timeout issue Proofline flagged was confirmed by reading the code with the tool's help, and I reviewed and accepted the fix. I can explain every change and I'm responsible for them.

The prompts I submitted during the coding session are in the hidden HTML comment at the end of this description.

mohsen1 commented Nov 17, 2026

Copy link
Copy Markdown
Member

Codex

Closing as out of scope. We’re keeping the SDK focused on the existing API and small, necessary client helpers.

@mohsen1 mohsen1 closed this Nov 17, 2026
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.

2 participants