You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The chunker module previously had a circular dep with utils: utils
imported chunking at top level, but chunking did a lazy import of
`RateLimited` / `ServiceUnavailable` from utils inside
`_classify_chunk_error`. The lazy form existed only to defeat that
cycle. utils.py also reached across the boundary three times for
private chunker internals — `chunking._QUOTA_HEADER`,
`chunking._chunked_session.get()`, and `chunking._publish_session`.
Reasoning about the layer: `RateLimited` / `ServiceUnavailable` exist
*because of* the chunker — they're raised by utils.py's
`_raise_for_non_200` solely so `_classify_chunk_error` can dispatch
on them as resumable transient failures. The motivating consumer is
the chunker, so they belong in chunking.py.
Changes:
- Move `_RetryableTransportError`, `RateLimited`, `ServiceUnavailable`
from utils.py → chunking.py.
- Drop the lazy `from .utils import …` inside `_classify_chunk_error`.
- Add `chunking.get_active_session()` — public accessor for the
`_chunked_session` ContextVar so `_session()` in utils.py doesn't
reach into a private name.
- Hoist `_QUOTA_HEADER` to a top-level explicit import in utils.py
instead of `chunking._QUOTA_HEADER` ad-hoc.
- Update the two test files that imported `RateLimited` /
`ServiceUnavailable` from utils.py.
After this commit, chunking.py has zero runtime dependency on utils.py
(only docstring cross-references). The dep direction is now strictly
utils → chunking.
80/80 chunker + utils unit tests pass; ruff clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments