Skip to content

Generate TypedDict types for input-side models #666

@vdusek

Description

@vdusek

Context

In PR #663 (Accept Pydantic models as alternatives to dicts in resource client methods), we introduced union types like dict | WebhookCreate so that users can pass Pydantic model instances instead of plain dicts. However, the dict part of the union is still untyped — users passing dicts get no type safety or autocompletion.

As discussed in this comment, we could replace the generic dict with generated TypedDict types for an additional layer of type safety. For example, instead of dict | WebhookCreate, the signature could be WebhookCreateDict | WebhookCreate, where WebhookCreateDict is a TypedDict with the same fields.

Proposal

  • Investigate generating TypedDict equivalents from the Pydantic models (or directly from the OpenAPI spec) for models that are used as input parameters.
  • Integrate the generation into the existing model generation pipeline (uv run poe generate-models).
  • Replace dict with the corresponding TypedDict in resource client method signatures.

Metadata

Metadata

Assignees

Labels

t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions