Skip to content

Emit Python variants as tagged case classes - #136

Draft
VegetarianOrc wants to merge 3 commits into
mainfrom
amazzeo/variant-customization
Draft

Emit Python variants as tagged case classes#136
VegetarianOrc wants to merge 3 commits into
mainfrom
amazzeo/variant-customization

Conversation

@VegetarianOrc

Copy link
Copy Markdown
Contributor

Summary

  • Generate one slotted dataclass per Python WIT variant case and expose a union alias.
  • Add direct JSON transfer converters for records and resources containing variants.
  • Update protobuf oneof conversion, generated samples, documentation, and tests to use case classes.

Breaking change

  • Python WIT variants now use generated case objects instead of tagged tuples.
  • WIT results and JSON Schema oneOf behavior are unchanged.

Validation

  • ./scripts/validate.sh

raise ValueError("missing required field GenericResponse.context")
if "completion" not in value:
raise ValueError("missing required field GenericResponse.completion")
(_context_t_type, _output_t_type, _metadata_t_type) = typing.get_args(type_hint)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are used??? lol

Keep non-protobuf variants as tagged tuples and generate protobuf oneof cases as tag-free dataclasses. Dispatch protobuf conversion by case class identity without registering default variant transfer converters.
Keep oneof discovery, case naming, and dataclass rendering in the protobuf-specific Python module. Expose a generic variant block integration point from the main Python generator.
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.

1 participant