Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0834a2c
feat: add typeddict models-mode for Python HTTP client emitter
Apr 21, 2026
27c8bfb
Enhance Python HTTP client emitter with TypedDict support
iscai-msft Apr 21, 2026
c1487f8
add discriminator
Apr 21, 2026
02e6f35
Merge branch 'python/addTypedDict' of https://github.com/iscai-msft/t…
Apr 21, 2026
2647828
Merge branch 'main' of https://github.com/microsoft/typespec into pyt…
Apr 21, 2026
3a125b8
feat: return JSON for typeddict responses, drop NotRequired
Apr 23, 2026
e0569db
feat: add wire name mock API tests for typeddict naming spec
Apr 23, 2026
3e5c0ef
fix: remove redundant JSON overload for typeddict mode
Apr 23, 2026
f76c88d
fix: remove unused _deserialize import in typeddict mode
Apr 23, 2026
2401b66
fix: remove all unused imports in typeddict generated code
Apr 23, 2026
57bf76a
Merge branch 'main' into python/addTypedDict
iscai-msft Apr 24, 2026
47b5024
format and lint
Apr 27, 2026
87ea0a1
Merge branch 'python/addTypedDict' of https://github.com/iscai-msft/t…
Apr 27, 2026
95db199
fix: define JSON type alias in TypedDictModelType imports
Apr 28, 2026
37806df
switch to always generating typeddicts as typing hints
May 5, 2026
18786e3
switch to always generating typeddicts as typing hints
May 5, 2026
8d323ac
Merge branch 'python/addTypedDict' of https://github.com/iscai-msft/t…
May 5, 2026
db10eeb
move discriminated union to types.py
May 6, 2026
841b2ee
Merge branch 'main' of https://github.com/microsoft/typespec into pyt…
May 6, 2026
a206181
format
May 6, 2026
9572470
add for output as well
May 6, 2026
cdcedf5
add e2e tests
May 6, 2026
1d1d7c6
update unions serializer to get around pyright issue
May 6, 2026
f5e1f7d
fix: resolve pylint and pyright errors in generated types.py
May 7, 2026
f5f9300
Merge branch 'main' of https://github.com/microsoft/typespec into pyt…
May 11, 2026
f3be83c
fix pylint and pyright in generated code
May 11, 2026
6a34daf
Merge branch 'main' of https://github.com/microsoft/typespec into pyt…
May 11, 2026
bf7ef34
fix: move discriminated union aliases from _unions.py to types.py
May 11, 2026
e6b1b52
fix: topologically sort discriminated union aliases in types.py
May 11, 2026
df17af5
fix: skip model imports in types.py regardless of namespace
May 11, 2026
cedece0
fix: skip imports for discriminated base models in types.py
May 11, 2026
4497199
fix: sort TypedDict properties to avoid builtin name shadowing
May 11, 2026
7c8bf77
fix: handle reserved words in TypedDict field names comprehensively
May 11, 2026
136e247
fix: generate types.py per namespace instead of only at top level
May 11, 2026
b14f874
fix: correct cross-namespace imports in per-namespace types.py
May 12, 2026
c67d633
feat: combine regenerate scripts and add typeddict variant packages
May 12, 2026
1dd8314
feat: add client-naming-typeddict variant package
May 12, 2026
48d2aed
refactor: remove unnecessary is_response pops from TypedDictModelType
May 12, 2026
a130bfc
fix: use TypedDict dicts instead of model classes in naming test
May 12, 2026
6a15774
fix: skip self-import in types.py and unused _deserialize for typed-d…
May 13, 2026
3789713
fix: skip _models prefix for internal models in types.py annotations
May 13, 2026
762d694
merge: resolve upstream/main conflict, inline regenerate-common.ts ch…
May 20, 2026
bd83e9f
Merge branch 'main' of https://github.com/microsoft/typespec into pyt…
May 26, 2026
6c0ee44
switch to models-mode=typeddict to represent td only, generate union …
May 26, 2026
6d75f07
don't conflate optional and nullable
May 26, 2026
27113ce
format and lint
May 26, 2026
1de57f4
fix: address PR review comments for TypedDict support
May 27, 2026
a88d471
lint
May 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .chronus/changes/python-addTypedDict-2026-3-21-17-47-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: feature
packages:
- "@typespec/http-client-python"
---

[python] Always generate `TypedDict` typing hints for input models in the `types.py` file, and named union aliases in the `_unions.py` file
5 changes: 3 additions & 2 deletions packages/http-client-python/emitter/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ async function onEmitMain(context: EmitContext<PythonEmitterOptions>) {
const yamlMap = emitCodeModel(sdkContext);
const parsedYamlMap = walkThroughNodes(yamlMap);

// Python emitter requires an SDK client in the TypeSpec
if (sdkContext.sdkPackage.clients.length === 0) {
// Python emitter requires an SDK client in the TypeSpec (unless models-only typeddict mode)
const modelsMode = (sdkContext.emitContext.options as any)["models-mode"];
if (sdkContext.sdkPackage.clients.length === 0 && modelsMode !== "typeddict") {
reportDiagnostic(program, {
code: "no-sdk-clients",
target: NoTarget,
Expand Down
2 changes: 2 additions & 0 deletions packages/http-client-python/emitter/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ function emitProperty(
// Python convert all the type of file part to FileType so clear these models' usage so that they won't be generated
addDisableGenerationMap(context, property.type);
}
const isNullable = !isMultipartFileInput && sourceType.kind === "nullable";
return {
clientName: getClientName(property),
isExactName: property.isExactName,
Expand All @@ -242,6 +243,7 @@ function emitProperty(
: property.serializationOptions?.json?.name) ?? property.name,
type: getType(context, sourceType),
optional: property.optional,
nullable: isNullable,
description: property.summary ? property.summary : property.doc,
addedOn: getAddedOn(context, property),
apiVersions: property.apiVersions,
Expand Down
Loading
Loading