fix: Preserve count=0 in RunClient's charge (#751)
## Summary `RunClient.charge` (sync + async) built the request body with `'count': count or 1`. Because `or` treats `0` as falsy, a caller passing `count=0` — e.g. `count=len(batch)` for an empty batch, or a defensive no-op — was silently sent as `count=1`. On a pay-per-event billing endpoint that's a real overcharge, not a cosmetic bug. ## Fix Changed the signature from `count: int | None = None` to `count: int = 1` and pass `count` through to the request body unchanged. `0` now reaches the server as `0`; the default `1` is expressed in the signature instead of via a fallback. Docstring updated to reflect the new contract. ## Tests `tests/unit/test_run_charge.py` parametrizes the sync and async clients over `count` values `0`, `1`, `5` and asserts the value lands in the request body verbatim. The `0` case fails on `master` and passes here. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
V
Vlada Dusek committed
0a8942c3a5728689e28e0273938a3509ebb5f58d
Parent: 4b426dd
Committed by GitHub <noreply@github.com>
on 4/27/2026, 8:08:01 AM