refactor: make the code easier to read

This commit is contained in:
mateo-berri 2026-07-14 13:58:16 -07:00
parent ab87ebe26d
commit a21669aaef

View file

@ -102,7 +102,9 @@ class _CrossedLimit:
spent: int
def _spend_until_blocked_or_crossed(client: QuotaClient, key: str, first: _FirstOk) -> _BlockedByReservation | _CrossedLimit:
def _spend_until_blocked_or_crossed(
client: QuotaClient, key: str, first: _FirstOk
) -> _BlockedByReservation | _CrossedLimit:
"""Drive chat traffic, summing each body's actual usage.total_tokens, until
the limiter blocks (which the reservation may do before the actual spend
crosses the limit) or the actual spend reaches the limit."""
@ -238,8 +240,8 @@ class TestKeyRateLimits:
f"success response must report the key's request limit, headers: "
f"{ {k: v for k, v in first.headers.items() if 'ratelimit' in k} }"
)
assert first.headers.get("x-ratelimit-api_key-remaining-requests") == "4", (
f"first call against rpm_limit=5 must leave 4 remaining, got "
assert first.headers.get("x-ratelimit-api_key-remaining-requests") == str(5 - 1), (
f"first call against rpm_limit=5 must leave {5 - 1} remaining, got "
f"{first.headers.get('x-ratelimit-api_key-remaining-requests')!r}"
)
assert first.headers.get("x-ratelimit-api_key-limit-tokens") == "100000", (