Skip to content

[python] Emit TypedDicts as a patchable types/ package - #11370

Closed
Libba Lawrence (l0lawrence) with Copilot wants to merge 4 commits into
mainfrom
copilot/emit-typeddicts-in-types-folder
Closed

Libba Lawrence (l0lawrence) with Copilot wants to merge 4 commits into
mainfrom
copilot/emit-typeddicts-in-types-folder

Conversation

Copilot AI commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

TypedDict generation currently emits a standalone types.py, which makes customization inconsistent with the existing patchable models/ layout. This change moves TypedDict output into a types/ package so generated type surfaces can be patched without editing generated files directly.

  • Generate a patchable types/ package

    • Replace per-namespace types.py with:
      • types/__init__.py
      • types/_types.py
      • types/_patch.py
    • Keep the public import surface stable through types/__init__.py while isolating generated content in _types.py.
  • Update TypedDict import resolution

    • Adjust type and enum import generation to resolve correctly from within the nested types package.
    • Preserve same-namespace vs cross-namespace behavior for TypedDicts, enums, and model references.
  • Clean up legacy output on regen

    • Remove stale top-level types.py when regenerating into the new package layout to avoid duplicate or conflicting type surfaces.
  • Add focused coverage

    • Add unit tests for the new generated file structure and legacy types.py cleanup behavior.

Example generated layout:

from sample.types import WidgetUpdate
sample/
  types/
    __init__.py
    _types.py
    _patch.py

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: l0lawrence <100643745+l0lawrence@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Jul 23, 2026
Copilot AI changed the title [WIP] Emit typeddicts in a folder /types/ for patching [python] Emit TypedDicts as a patchable types/ package Jul 23, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@11370

commit: 271cb7b

@github-actions

github-actions Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:4da8bc856581babb8cb705ed9a0199141dff296b vs this PR.

Diff summary: 378 file(s), +6716 / -43

Rendered diff: inline on the run summary, or the emitter-diff-html artifact.

Informational check (eng/emitter-diff); does not block the PR.

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-python
Show changes

@typespec/http-client-python - fix ✏️

Generate TypedDict outputs in a patchable types/ package with _types.py and _patch.py instead of a standalone types.py file.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Aug 11, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Hi @Copilot. Your PR has had no update for 14 days and it is marked as a stale PR. If it is not updated within 14 additional days, the PR will automatically be closed. If you want to refresh the PR, please remove the stale label.

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Hi @Copilot. The PR will be closed since the PR has no update for 28 days. If this is still relevant please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python stale Mark a PR that hasn't been recently updated and will be closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python] emit typeddicts in a folder /types/ to allow for patching

2 participants