You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(types): codegen multi-emission of Creative/Package/etc. breaks Sequence covariant override on required response fields #642
datamodel-codegen emits subordinate types (`Creative`, `Package`, `MediaBuyDelivery`, etc.) once per response file. The public alias in `adcp.types` resolves to one specific emission, but the response type's field references a different local emission with the same name.
…fails under mypy --strict regardless of #624's Sequence widening, because `_Ext` is a subclass of one `Creative` and the parent expects a different one.
Affected response types (likely incomplete)
Each of these has a field whose element type is locally re-emitted rather than imported from the canonical module:
(These are the same response types where #624's Sequence widening produces incomplete coverage — the widening is necessary but not sufficient because of this codegen-side issue.)
Proposed fix
Two paths:
A) Codegen-side: prefer cross-file import over local re-emission. When datamodel-codegen sees that `Creative` is already defined in a sibling module (e.g. `creative/creative_item.py` or `core/creative.py`), import it rather than re-emit. Same shape, same type identity, override compatibility restored.
B) Post-processor: rewrite all `X` references in a generated file to import from the canonical module. A new function in `scripts/post_generate_fixes.py` that, for each multi-emitted type on an allowlist, replaces local class definitions with `from .canonical_module import X` and keeps the rest of the file pointing at the imported reference.
Approach A is structurally cleaner; approach B is more contained and safer if the canonical-module mapping is unambiguous.
This issue tracks the type-identity half of the adopter override-pattern friction. #624 (Sequence widening) is required first — without it, even cases where the type identity is correct would still hit list-invariance `[assignment]` errors. After both land, the full Critical Pattern #1 override should typecheck cleanly under mypy --strict with zero `# type: ignore` lines.
How surfaced
While extending the regression test for #624 to cover required-list overrides (`tests/type_checks/extend_response_with_sequence.py`), the override of `ListCreativesResponse.creatives: list[_InternalCreative]` still failed with `[assignment]` even after Sequence widening. Spike traced the failure to type identity, not variance.
My take: The type-identity fix is well-scoped and the proposed post-processor approach (Approach B in the issue body) is the safer path — a targeted allowlist rewrite in post_generate_fixes.py that replaces local re-emissions with cross-file imports. It can't land before #624 resolves because the Sequence widening is a prerequisite; however, since both fixes touch the same file and same PR author, folding #642's scope into PR #640 before merge is a cleaner delivery than a follow-on PR.
Premise correction — multi-emission is intentional, not a bug
After investigating the actual field shapes across emissions, the original framing was wrong. The "duplicated" classes have completely different field sets, not nominal duplicates:
These are genuinely different types that happen to share names across spec contexts. There's no "canonical version" to import; the local emissions are correct and load-bearing.
What this means
The codegen behavior is correct. Each response file inlines the variant of the type that schema slice actually defines. Re-using a single canonical class would be semantically wrong because the shapes differ.
Approach B (replace local class with import) doesn't apply — there's no equivalent class to import in most cases.
The SDK can't fix this without a spec-level change (rename to disambiguate) or a codegen-level change (emit with disambiguated names like `_ListCreativesResponseCreative`).
What adopters need to know (the actual gap)
The friction is import-path discoverability: an adopter extending `ListCreativesResponse` should import `Creative` from `adcp.types.generated_poc.creative.list_creatives_response`, not `adcp.types.Creative`. The latter resolves to a different class.
The salesagent `# type: ignore[assignment]` lines on these overrides are warranted in part because the imports are wrong — the canonical fix is changing the import, not bypassing the type check.
Proposed action
Close this issue as not-actionable on the SDK side.
File a docs PR that documents the canonical import path for response-extension patterns: extending ``? Import its sub-types from `<response_module>`, not from `adcp.types`.
Spec-level disambiguation (separate ask) — rename the schemas so `Creative` in three places becomes `Creative`, `CreativeDeliveryRecord`, `CreativeSyncResult`. That's an upstream `adcontextprotocol/adcp` ask, not this repo.
Closing as won't-fix-on-SDK-side; docs PR follows.
Activity
fix(types): address pre-merge review on #624 — bound regex to class, …
bokelley commentedon May 10, 2026
Triage
Classification: Bug
Bucket(s): client
Status: deferred
What the experts said:
scripts/post_generate_fixes.py.My take: The type-identity fix is well-scoped and the proposed post-processor approach (Approach B in the issue body) is the safer path — a targeted allowlist rewrite in
post_generate_fixes.pythat replaces local re-emissions with cross-file imports. It can't land before #624 resolves because the Sequence widening is a prerequisite; however, since both fixes touch the same file and same PR author, folding #642's scope into PR #640 before merge is a cleaner delivery than a follow-on PR.Blocked-on: #624 — resurfaces on merge.
Triaged by Claude Code. Session: https://claude.ai/code/session_01XgqM4ULaBn2Cx94tPA5qEt
Generated by Claude Code
feat(types): widen extension-point list[X] to Sequence[X] (#624) (#640)
bokelley commentedon May 10, 2026
Premise correction — multi-emission is intentional, not a bug
After investigating the actual field shapes across emissions, the original framing was wrong. The "duplicated" classes have completely different field sets, not nominal duplicates:
`Creative`:
`Package`:
`MediaBuy`:
These are genuinely different types that happen to share names across spec contexts. There's no "canonical version" to import; the local emissions are correct and load-bearing.
What this means
What adopters need to know (the actual gap)
The friction is import-path discoverability: an adopter extending `ListCreativesResponse` should import `Creative` from `adcp.types.generated_poc.creative.list_creatives_response`, not `adcp.types.Creative`. The latter resolves to a different class.
The salesagent `# type: ignore[assignment]` lines on these overrides are warranted in part because the imports are wrong — the canonical fix is changing the import, not bypassing the type check.
Proposed action
Closing as won't-fix-on-SDK-side; docs PR follows.
docs: response-extension import path guidance for context-specific sc…
docs: response-extension import path guidance for context-specific sc…