Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

  • Extends the BeforeValidator coercion pattern from feat: improve type ergonomics for library consumers #103 to response types
  • Response types now accept dict coercion for context and ext fields
  • Subclass list acceptance for products, creatives, formats, packages, errors, creative_agents, and media_buy_deliveries

This eliminates the need for cast() calls when constructing response objects with subclass instances.

Response types with coercion:

  • GetProductsResponse
  • ListCreativesResponse
  • ListCreativeFormatsResponse
  • CreateMediaBuyResponse1
  • GetMediaBuyDeliveryResponse

Test plan

  • Added tests for response type dict coercion
  • Added tests for response type subclass list acceptance
  • Added tests for response serialization roundtrip
  • All existing type coercion tests still pass

Closes #105

🤖 Generated with Claude Code

bokelley and others added 2 commits December 20, 2025 22:15
Apply the same BeforeValidator coercion pattern from PR #103 to response
types. This eliminates the need for cast() calls when constructing
response objects with subclass instances or dict coercion.

Response types now support:
- Dict coercion for context/ext fields
- Subclass list acceptance for products, creatives, formats, packages,
  errors, and media_buy_deliveries

Closes #105

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update response type tests to import from public API (adcp.types)
  instead of internal generated_poc modules
- Use semantic alias CreateMediaBuySuccessResponse instead of
  CreateMediaBuyResponse1 for clearer intent
- Add clarifying comments for # type: ignore annotations explaining
  Python list covariance limitation
- Add tests for GetProductsResponse.products subclass acceptance
- Add tests for errors field coercion
- Document _ergonomic.py in CLAUDE.md import architecture section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley bokelley merged commit d31c4d8 into main Dec 21, 2025
8 checks passed
@bokelley bokelley deleted the bokelley/fix-issue-105 branch December 21, 2025 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: extend type ergonomics to response types

2 participants