Skip to content

Fix V2Gjson emitter to type nested-struct fields as dict[str, Any]; regenerate all 8 modules #39

@JakeMG-INL

Description

@JakeMG-INL

Parent

#8

What to build

Fix a type-annotation bug in tools/codegen/v2gjson_emitter.py's _param_type function: fields with kind="struct" (libcbv2g-declared nested structs like RelativeTimeInterval: struct din_RelativeTimeIntervalType) currently fall through to the default return "int" branch, producing constructor signatures like RelativeTimeInterval: int|None = None when the legal value at runtime is the dict returned by the corresponding nested constructor (RelativeTimeIntervalType(...)).

Add a branch if field.kind == "struct": return "dict[str, Any]" (mirroring the existing kind="array"list[dict[str, Any]] branch). Regenerate all eight V2Gjson modules from the emitter and verify no other change to constructor bodies occurs (the runtime _value_expr already passes the value through unchanged for kind="struct").

The C++ marshalers (src/generated/*_marshalers.generated.cpp) confirm the contract: outJson["RelativeTimeInterval"] = getJson_RelativeTimeIntervalType(...) emits a JSON object, and getDoc_RelativeTimeIntervalType(...) consumes one. This is purely a static-type-annotation fix; no runtime behavior changes.

Per ADR-0014, this fix is in the v1.0 window — shipping the broken annotation and fixing in v1.1 would make a dict|None annotation a MAJOR-bump change post-tag.

Acceptance criteria

  • tools/codegen/v2gjson_emitter.py _param_type returns "dict[str, Any]" for kind="struct" fields
  • All eight V2Gjson modules regenerated; diff shows only the affected annotation changes
  • tests/integration/ round-trip suites still pass
  • Spot-check at least three constructors that have nested-struct fields (e.g. PMaxScheduleEntryType, SalesTariffEntryType, ISO-2 / ISO-20 analogs) to confirm the annotation is now dict[str, Any] | None

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions