Skip to content

Codec types

Import JSONValue and TypeHint from duron.codec.

JSON values

JSONValue describes the recursive values a codec can persist: JSON scalars, lists, and dictionaries with string keys. Floats must also be finite; this is a runtime requirement that the type alias cannot express.

Type hints

TypeHint[T] represents a runtime annotation for values of type T, such as int or list[str]. It appears in custom codec APIs and does not validate a value by itself. See the codec reference.

Port payload annotations

Port payloads support Literal, Annotated, and TypeAliasType aliases, including generic and recursive aliases. Native aliases declared with the type statement are supported on Python 3.12 and later. Aliases do not add serialization support: tuples and other non-JSON Python values still need a custom codec.

Recursive type representing any valid JSON value.

A type expression or the internal unspecified-type sentinel.