diff --git a/.chronus/changes/add-python-post-paging-lro-with-body-test-2026-7-22-2-4-0.md b/.chronus/changes/add-python-post-paging-lro-with-body-test-2026-7-22-2-4-0.md deleted file mode 100644 index f0b0c763632..00000000000 --- a/.chronus/changes/add-python-post-paging-lro-with-body-test-2026-7-22-2-4-0.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add mock API tests for the new ARM operation-templates scenarios (`postPagingLroWithBody`, `getLro`, `postActionPaging`, `markAsPageable`, `Legacy.routedGet`, and `Legacy.createOrReplaceOptionalBody`). diff --git a/.chronus/changes/fix-python-emitter-invalid-type-annotations-2026-4-18-0-0-0.md b/.chronus/changes/fix-python-emitter-invalid-type-annotations-2026-4-18-0-0-0.md deleted file mode 100644 index c17c99318de..00000000000 --- a/.chronus/changes/fix-python-emitter-invalid-type-annotations-2026-4-18-0-0-0.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/http-client-python" ---- - -Fix invalid Python type annotations generated in `types.py` files. Internal enums used as TypedDict fields are now imported (as a bare symbol) from their private `_enums` submodule so the annotation resolves; duplicate runtime + `TYPE_CHECKING` imports of the same symbol are deduplicated to avoid `no-redef`; and TypedDicts that change an inherited field's requiredness are emitted as a flat (non-inheriting) TypedDict to satisfy PEP 589. diff --git a/.chronus/changes/forward-python-package-index-environment-2026-8-7.md b/.chronus/changes/forward-python-package-index-environment-2026-8-7.md deleted file mode 100644 index 1bca0d34314..00000000000 --- a/.chronus/changes/forward-python-package-index-environment-2026-8-7.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/http-client-python" ---- - -Forward package index and Python mirror environment variables to tox test environments so tests can install dependencies from configured feeds. diff --git a/.chronus/changes/python-arm-service-group-tests-2026-7-27-8-59-27.md b/.chronus/changes/python-arm-service-group-tests-2026-7-27-8-59-27.md deleted file mode 100644 index 330b02ebc10..00000000000 --- a/.chronus/changes/python-arm-service-group-tests-2026-7-27-8-59-27.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add test coverage for Azure ARM service group extension resources and ARM resource identifier group scope diff --git a/.chronus/changes/python-custom-error-status-mapping-2026-6-16-9-52-50.md b/.chronus/changes/python-custom-error-status-mapping-2026-6-16-9-52-50.md deleted file mode 100644 index 520072bfca1..00000000000 --- a/.chronus/changes/python-custom-error-status-mapping-2026-6-16-9-52-50.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/http-client-python" ---- - -Always populate the operation `error_map` with the standard azure-core error types (401 → `ClientAuthenticationError`, 404 → `ResourceNotFoundError`, 409 → `ResourceExistsError`, 304 → `ResourceNotModifiedError`), even when a customized error model covers those status codes. Previously, a standard status code covered by a customized ranged or default error model fell back to a generic `HttpResponseError`; it now raises its dedicated error type via `map_error`. The customized error body continues to be deserialized and attached to the `HttpResponseError` raised for other (non-standard) status codes. diff --git a/.chronus/changes/python-enable-arm-operationtemplates-tests-2026-08-17.md b/.chronus/changes/python-enable-arm-operationtemplates-tests-2026-08-17.md deleted file mode 100644 index dfa70624d02..00000000000 --- a/.chronus/changes/python-enable-arm-operationtemplates-tests-2026-08-17.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Enable sync and async Azure ARM operation templates test coverage. diff --git a/.chronus/changes/python-spector-tests-arm-optemplate-clientapiversions-2026-7-27-8-55-0.md b/.chronus/changes/python-spector-tests-arm-optemplate-clientapiversions-2026-7-27-8-55-0.md deleted file mode 100644 index adc0284cc01..00000000000 --- a/.chronus/changes/python-spector-tests-arm-optemplate-clientapiversions-2026-7-27-8-55-0.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-client-python" ---- - -Add mock API tests for new Spector scenarios: ARM operation templates (Legacy RoutedOperations, LRO on GET, POST LRO with paging body, POST action paging, markAsPageable) and `@clientApiVersions` decorator diff --git a/.chronus/changes/structured-streaming-2026-0-0.md b/.chronus/changes/structured-streaming-2026-0-0.md deleted file mode 100644 index 0c3ec139d78..00000000000 --- a/.chronus/changes/structured-streaming-2026-0-0.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/http-client-python" ---- - -Generate structured streaming client methods: operations whose HTTP response is a JSONL (`application/jsonl`) or SSE (`text/event-stream`) stream now return `Stream[T]` / `AsyncStream[T]`, yielding deserialized model instances instead of raw bytes. - -The `Stream` / `AsyncStream` runtime (plus the JSONL / SSE decoders) is vendored at `_utils/streaming_base.py` and depends only on the released core runtime for the flavor — `azure.core.rest` for the Azure flavor and `corehttp.rest` for the unbranded flavor. These types are an internal implementation detail and are not part of the package's public API. - -```python -stream = client.receive() -for thing in stream: - ... -``` - -For SSE streams, the most recently received event `id` and `retry` value (if provided by the server) are exposed via `stream.last_event_id` / `stream.retry`. Event envelopes yield the `@Events.data` payload using its payload type and content type. JSON payload media types (`application/json` and `+json`) are decoded as JSON, while other SSE payload media types remain UTF-8 text for type-specific deserialization. Pass `last_event_id=` to an SSE operation to send `Last-Event-ID` when manually resuming a stream. diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index ef23664f401..c00684412d4 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log - @typespec/http-client-python +## 0.37.0 + +### Features + +- [#11594](https://github.com/microsoft/typespec/pull/11594) Generate structured streaming client methods: operations whose HTTP response is a JSONL (`application/jsonl`) or SSE (`text/event-stream`) stream now return `Stream[T]` / `AsyncStream[T]`, yielding deserialized model instances instead of raw bytes. + +### Bug Fixes + +- [#11638](https://github.com/microsoft/typespec/pull/11638) Fix invalid Python type annotations generated in `types.py` files. Internal enums used as TypedDict fields are now imported (as a bare symbol) from their private `_enums` submodule so the annotation resolves; duplicate runtime + `TYPE_CHECKING` imports of the same symbol are deduplicated to avoid `no-redef`; and TypedDicts that change an inherited field's requiredness are emitted as a flat (non-inheriting) TypedDict to satisfy PEP 589. +- [#11300](https://github.com/microsoft/typespec/pull/11300) Forward package index and Python mirror environment variables to tox test environments so tests can install dependencies from configured feeds. +- [#11250](https://github.com/microsoft/typespec/pull/11250) Always populate the operation `error_map` with the standard azure-core error types (401 → `ClientAuthenticationError`, 404 → `ResourceNotFoundError`, 409 → `ResourceExistsError`, 304 → `ResourceNotModifiedError`), even when a customized error model covers those status codes. Previously, a standard status code covered by a customized ranged or default error model fell back to a generic `HttpResponseError`; it now raises its dedicated error type via `map_error`. The customized error body continues to be deserialized and attached to the `HttpResponseError` raised for other (non-standard) status codes. + + ## 0.36.0 ### Features diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 17f49dd347b..de0aa024175 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-client-python", - "version": "0.36.0", + "version": "0.37.0", "author": "Microsoft Corporation", "description": "TypeSpec emitter for Python SDKs", "homepage": "https://typespec.io",