Skip to content

refactor(internal): extract body-cap module out of client.py#97

Merged
lesnik512 merged 3 commits into
mainfrom
worktree-body-cap-module-extraction
Jul 13, 2026
Merged

refactor(internal): extract body-cap module out of client.py#97
lesnik512 merged 3 commits into
mainfrom
worktree-body-cap-module-extraction

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

  • Extracts the max_response_body_bytes body-capping subsystem out of client.py into a new _internal/body_cap.py, and folds the two httpx2-exception-mapper context managers into the existing _internal/exception_mapping.py — pure move, no behavior change.
  • client.py shrinks by ~200 lines to a 3-name import for body-cap plus two for exception mapping; _build_default_decoders stays put per architecture/decoders.md.
  • Fixes a doc-location claim in architecture/errors.md/client.md ("error-mapping table lives at the terminal in client.py") that this branch makes flatly false.

Design: planning/changes/2026-07-13.01-body-cap-module-extraction.md

Test plan

  • just test — 766 passed, 100% coverage
  • just lint-ci — ruff format/check, ty check, planning validator all clean
  • just docs-build — mkdocs --strict clean
  • Task-scoped review (spec + quality): Approved
  • Final whole-branch review: Ready to merge = Yes, no Critical/Important findings

…om client.py

Move the max_response_body_bytes enforcement code (validation, capped
sync/async reads, and their helpers) into a new _internal/body_cap.py, and
move the _httpx2_exception_mapper(/_sync) context managers into the
existing _internal/exception_mapping.py alongside map_httpx2_exception.
Pure refactor: no behavior change, only import paths move. client.py drops
~160 lines of self-contained logic it never needed class access to.

Rename tests/test_capped_read(_props).py to tests/test_body_cap(_props).py
to match, and relocate test_parse_content_length out of
test_client_stream.py into the renamed test_body_cap.py.
errors.md and client.md said the httpx2-exception-mapping table
"lives at the terminal in client.py" — true before this branch, but
the body-cap extraction moved the last mapping code out of client.py
entirely, into _internal/exception_mapping.py. Distinguish where the
table lives from where it fires.
@lesnik512 lesnik512 merged commit bcce8a7 into main Jul 13, 2026
6 checks passed
@lesnik512 lesnik512 deleted the worktree-body-cap-module-extraction branch July 13, 2026 10:42
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