Skip to content

[Python Codegen] Support plain class style with runtime XML/JSON binding #60

Description

@nth-bailey

Context

#50 proposed --lang python --style class, but the current generator emits dataclasses or Pydantic models only. polyxml-python discovers fields through __dataclass_fields__ or Pydantic model_fields, so merely omitting @dataclass would produce a class whose XML/JSON fields are invisible to the runtime.

Scope

  • Define the plain-class field declaration and metadata format, including XML name, namespace, attribute/text kind, defaults, optional fields, and lists.
  • Add generated --style class output for the Python backend and support it in both [[generate]] and [codegen.python] manifests. Decide whether this style is compatible with Pydantic or restrict it to the standard backend.
  • Teach the Python runtime to discover, instantiate, serialize, and deserialize these classes, including nested and inherited models and generated from_xml/to_xml/JSON helpers.
  • Test generated classes end to end, including round trips, default values, field metadata, inheritance, and xsi:type where applicable. Preserve the existing dataclass and Pydantic defaults.
  • Update the compiler guide's supported-style table when the implementation is complete.

Related: #50, PR #56.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions