You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
An explicit codec makes an optional field required #77
Priority: medium. A field given a codec (codec=, UseCodec(...)) is never wrapped as optional, so None is refused even when the annotation allows it and it is the default:
Attr[dict[str, Any] | None] = field(default=None, codec=JsonCodec()) fails on construction with its own default ("must not be None").
Attr[datetime | None] = field(default=None, codec=DateTimeCodec("iso_z")), the guides' way to give one field its own timestamp format, fails the same way.
Attr[Literal["on", "off", None]] fails too.
Pydantic Annotated[datetime | None, UseCodec(...)] = None validates, but create() fails with "is required".
Where:python/dynamoxy/schema.py (the codec of a field with codec= is used as given), python/dynamoxy/codecs.py (UseCodec ignores | None; Literal[..., None]).
Fix: wrap an explicit codec in OptionalCodec when the annotation includes None.
Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.
Activity