diff --git a/.chronus/changes/fix-python-raw-bytes-encoding-2026-10-21.md b/.chronus/changes/fix-python-raw-bytes-encoding-2026-10-21.md new file mode 100644 index 00000000000..be1c852eb45 --- /dev/null +++ b/.chronus/changes/fix-python-raw-bytes-encoding-2026-10-21.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Preserve the ytes type for raw bytes encoded as ytes with a wire type, preventing regression to string and preserving binary streaming. \ No newline at end of file diff --git a/packages/http-client-python/emitter/src/types.ts b/packages/http-client-python/emitter/src/types.ts index d3f1d6778de..8a063d53c82 100644 --- a/packages/http-client-python/emitter/src/types.ts +++ b/packages/http-client-python/emitter/src/types.ts @@ -477,7 +477,7 @@ const sdkScalarKindToPythonKind: Record = { const supportedPythonEncodings = new Map>([ ["boolean", new Set(["string"])], ["integer", new Set(["string"])], - ["bytes", new Set(["base64", "base64url"])], + ["bytes", new Set(["base64", "base64url", "bytes"])], ]); function emitBuiltInType( diff --git a/packages/http-client-python/emitter/test/types.test.ts b/packages/http-client-python/emitter/test/types.test.ts index 750c357a670..9407691b11a 100644 --- a/packages/http-client-python/emitter/test/types.test.ts +++ b/packages/http-client-python/emitter/test/types.test.ts @@ -50,7 +50,7 @@ describe("typespec-python: built-in types", () => { }, ); - it.each(["base64", "base64url"] as const)("preserves bytes encoded as %s", (encode) => { + it.each(["base64", "base64url", "bytes"] as const)("preserves bytes encoded as %s", (encode) => { deepStrictEqual( emitBuiltInType(createBuiltInType("bytes", encode, createBuiltInType("string"))), {