Skip to content

registry

Classes:

  • Registry

    A registry of storage schemes, serializers, and readers.

  • RegistryKwargs

    Arguments for creating a registry.

Registry

Registry(**kwargs: Unpack[RegistryKwargs])

A registry of storage schemes, serializers, and readers.

Methods:

get_default_storage

get_default_storage() -> Storage

Return the default storage for this registry.

get_serializer

get_serializer(name: str) -> Serializer

Get a serializer by its name.

get_serializer_by_content_type

get_serializer_by_content_type(
    content_type: str,
) -> Serializer

Get a serializer that can handle the given content type.

get_serializer_by_type

get_serializer_by_type(cls: type[T]) -> Serializer[T]

Get a serializer that can handle the given type or its parent classes.

get_storable

get_storable(class_id: UUID) -> type[Any]

Get a storable class by its ID.

get_storage

get_storage(name: str) -> Storage

Get a storage by its name.

get_stream_serializer

get_stream_serializer(name: str) -> StreamSerializer

Get a stream serializer by its name.

get_stream_serializer_by_content_type

get_stream_serializer_by_content_type(
    content_type: str,
) -> StreamSerializer

Get a stream serializer that can handle the given content type.

get_stream_serializer_by_type

get_stream_serializer_by_type(
    cls: type[T],
) -> StreamSerializer[T]

Get a stream serializer that can handle the given type or its base classes.

get_unpacker

get_unpacker(name: str) -> Unpacker

Get an unpacker by its name.

has_storable

has_storable(
    cls: type[Any], *, raise_if_missing: bool = False
) -> TypeGuard[type[Storable]]

Check if the given class is registered in this registry.

infer_unpacker

infer_unpacker(cls: type[S]) -> Unpacker[S]

Get the first unpacker that can handle the given type or its parent classes.

RegistryKwargs

Bases: TypedDict

Arguments for creating a registry.

Attributes:

default_storage instance-attribute

default_storage: bool | Storage

Whether to set a default storage used when saving (default: False).

modules instance-attribute

modules: Sequence[str | ModuleType] | None

Modules to import and extract registry attributes from.

registries instance-attribute

registries: Sequence[Registry] | None

Other registries to merge with this one.

serializers instance-attribute

serializers: Sequence[Serializer | StreamSerializer] | None

Serializers to register.

storables instance-attribute

storables: Sequence[type[Storable]] | None

Storable classes to register.

storages instance-attribute

storages: Sequence[Storage] | None

Storages to register.

unpackers instance-attribute

unpackers: Sequence[Unpacker] | None

Decomposers to register.