betty.serde.dump module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.serde.dump module

Provide a serialization API.

betty.serde.dump.DictDump

  A dump which is a dictionary whose keys are strings and values are serialized dumps.

  alias of `dict`[`str`, `DumpT`]

betty.serde.dump.Dump

  A serialized dump.

  alias of `bool` | `int` | `float` | `str` | `None` | `Sequence`[`Dump`] | `Mapping`[`str`, `Dump`]

betty.serde.dump.DumpType: TypeAlias = bool | int | float | str | None | list['Dump'] | dict[str, 'Dump']

  The Python types that define a serialized dump.

class betty.serde.dump.Dumpable

  Bases: `object`

  Instances can be dumped to serializable data.

  dump() → bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]

    Dump this instance to a portable format.

    Return type:

      `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]]

betty.serde.dump.ListDump

  A dump which is a list whose values are serialized dumps.

  alias of `list`[`DumpT`]

class betty.serde.dump.Void

  Bases: `object`

  A sentinel that describes the absence of a value.

  Using this sentinel allows for actual values to be `None`. Like `None`, `Void` is only ever used through its type, and never instantiated.

  static __new__(cls)

betty.serde.dump.VoidableDictDump

  A dump which is a dictionary whose keys are strings and values are serialized dumps, or that may be `betty.serde.dump.Void`

  alias of `dict`[`str`, `VoidableDumpT`]

betty.serde.dump.VoidableDump

  A serialized dump that may be `betty.serde.dump.Void`.

  alias of `bool` | `int` | `float` | `str` | `None` | `Sequence`[`Dump`] | `Mapping`[`str`, `Dump`] | `type`[`Void`]

betty.serde.dump.VoidableListDump

  A dump which is a list whose values are serialized dumps, or that may be `betty.serde.dump.Void`

  alias of `list`[`VoidableDumpT`]

betty.serde.dump.dump_default(dump, key, default_type)

  Add a key and value to a dump, if the key does not exist yet.

betty.serde.dump.minimize(dump: bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void] | list[bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]] | dict[str, bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]], voidable: bool = True) → bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]

  Minimize a configuration dump by removing any Void configurationfrom sequences and mappings.

  Parameters:

    - dump (`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`], `list`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]]], `dict`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]]]])

    - voidable (`bool`)

  Return type:

    `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]]

betty.serde.dump.none_void(value: bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]) → bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]

  Passthrough a value, but convert None to Void.

  Parameters:

    value (`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]])

  Return type:

    `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]]

betty.serde.dump.void_none(value: bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]) → bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]

  Passthrough a value, but convert Void to None.

  Parameters:

    value (`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]])

  Return type:

    `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]]