feat: land M1 — body abstractions, HTTP value types, Python 3.12 migr… · dexpace/python-sdk@bd829b1 · GitHub
Skip to content

Commit bd829b1

Browse files
OmarAlJarrahclaude
andcommitted
feat: land M1 — body abstractions, HTTP value types, Python 3.12 migration
Major reshape of the SDK core. M1 lands the body layer, new HTTP value types, and brings the codebase in line with the project styleguide. Body layer (replaces the Java/Okio-style `io/` module) - Drop `Source` / `Sink` / `BufferedSource` / `BufferedSink` / `Buffer` / `IoProvider` / `Io` / `TeeSink` / `DefaultIoProvider`. Python's stdlib (`bytes`, `bytearray`, `memoryview`, `BytesIO`, `BinaryIO`) covers the same surface idiomatically; Azure's corehttp confirms this is the right Python shape. - Add `RequestBody` as an `ABC` with `iter_bytes(chunk_size)` as the primary streaming surface; factories `from_bytes`, `from_string`, `from_form`, `from_stream`, `from_iter` cover common shapes. - Add `FileRequestBody` — replayable, re-opens the file each `iter_bytes`, transports can `isinstance`-check for zero-copy sendfile. - Add `LoggableRequestBody` — mirrors writes into a `BytesIO` tap with a configurable cap; `snapshot()` returns captured bytes. - Rewrite `ResponseBody` with `iter_bytes` / `bytes()` / `string()`; single-use stream-backed variant; in-memory bytes variant. - Add `LoggableResponseBody` — caches drained bytes for repeatable reads. New HTTP value types - `Url` + `QueryParams` — immutable URL parsing/serialisation, centralises `urllib.parse` interop. - `ETag` — frozen dataclass with `weak` flag, `parse`, strong/weak comparators. - `HttpRange` + `HttpRange.suffix(N)` — `Range`/`Content-Range` byte ranges. - `RequestConditions` — bundle of `If-Match` / `If-None-Match` / `If-Modified-Since` / `If-Unmodified-Since` with `apply_to(request)`. - `HttpHeaderName` — typed constants for ~55 IANA-registered headers; `Headers` API accepts `str | HttpHeaderName` everywhere. Python 3.12 migration (per the styleguide) - Bump floor from 3.8 to 3.12. Drop `typing_extensions` and the `Optional` / `Union` / `List` / `Dict` / `Tuple` imports. - Modern syntax across the codebase: `X | None`, built-in generics, `Self`, PEP 695 type parameters (`def f[T](x: T) -> T`), `StrEnum`. - Add `slots=True` to every frozen dataclass. - Google-style docstrings on M1 surface (older modules tracked in to-implement.md for sweep during M2). Tooling - `pyproject.toml` dev extras (pytest + pytest-cov + pytest-asyncio + ruff + mypy) and tool configs (`[tool.ruff]`, `[tool.mypy]`, `[tool.pytest.ini_options]`). - `mypy --strict` config (python_version 3.12), `ruff` rule set covering pycodestyle / pyflakes / isort / pep8-naming / bugbear / pyupgrade / simplify / ruff-specific. - `py.typed` marker (PEP 561). - 145 pytest cases covering Buffer-free body factories, every HTTP value type, Headers immutability + case-insensitivity, MediaType parse/includes/wildcards, Url/QueryParams round-trips, ETag/HttpRange serialisation, RequestConditions header fan-out, Request/Response with_* helpers, context promotion chain + ContextStore eviction + duplicate-id rejection. Docs - README and CLAUDE.md fully rewritten for the new surface, Python floor, and conventions. - to-implement.md revised after the Azure SDK study (pipeline + retry + auth + paging design decisions locked in) and updated to reflect M1 completion. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2c49741 commit bd829b1

68 files changed

Lines changed: 3282 additions & 1875 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 4 additions & 0 deletions

‎CLAUDE.md‎

Lines changed: 117 additions & 82 deletions

0 commit comments

Comments
 (0)