v0.5.0
Added
pathlib.Path(and anyPurePathsubclass:PurePosixPath,PureWindowsPath, etc.) is a first-class scalar field type. Wire format isstr(path); decoding restores the samePurePathsubclass. (#21)enum.StrEnumandenum.IntEnumare first-class scalar field types. String-valued and int-valued plainenum.Enumsubclasses also work; mixed-value enums raiseTypeNotSupportedError. The encoder accepts either an enum member or its raw value, soM.model_validate({"color": "red"})works the same asM(color=Color.RED). (#23)
Fixed
- TaggedUnion-typed fields now JSON-round-trip correctly when the variant is itself a TaggedUnion.
model_validate_jsonwalks each nested{"kind": "...", ...}payload through the discriminator registry instead of handing the dict straight to the variant-encoder. Direct construction with a dict child works too:BinOp(left={"kind": "lit", "value": 1}, ...)dispatches the same way. (#22) - TaggedUnion-typed fields consult
cls.__variants__live at encode and decode time, not snapshotted at field-classify time. Variants registered after a parent variant's field was classified (the canonical case is mutually recursive AST shapes:BinaryOp->ListLiteralandListLiteral->BinaryOp) participate fully, in either definition order. (#24)
Changed
docs/guide/types.mddocuments the Path family and the StrEnum / IntEnum / value-typed Enum branches alongside a workedStrEnumexample.docs/guide/unions.mddocuments recursive and mutually recursive variants, dict-dispatch on construction, and the JSON round-trip contract.
Full changelog: https://github.com/panproto/didactic/blob/main/CHANGELOG.md