registries.errors

Registry error classes.

New in version 1.0.

Exceptions

AlreadyRegisteredError([message])

The provided item is already registered.

AttrNotFoundUnregistrationError([message])

An item was not found by attribute for unregistration.

BaseRegistrationError([message])

Base class for registration errors.

BaseRegistryError([message])

Base class for a registry exception.

BaseRegistryItemLookupError([message])

Base class for errors in looking up an item from a registry.

BaseUnregistrationError([message])

Base class for unregistration errors.

InvalidItemRegistrationError([message])

An item could not be registered due to missing attributes.

ItemNotFoundLookupError([message])

An item could not be found in the registry.

ItemNotFoundUnregistrationError([message])

An item was not found for unregistration.

RegistrationConflictError([message])

The provided item conflicts with an item that is already registered.

UnsupportedRegistryAttributeError([message])

An attribute was referenced that is not supported by the registry.

exception registries.errors.BaseRegistryError(message: str | None = None, **kwargs)[source]

Bases: Exception

Base class for a registry exception.

New in version 1.0.

message_template: ClassVar[_FormatStr] = "Unspecified registry error. This is an implementation error with the application's custom registry error handling."

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__init__(message: str | None = None, **kwargs) None[source]

Initialize the error.

Parameters:

message (str, optional) –

An explicit error message as a %-based format string.

If not provided, message_template will be used.

exception registries.errors.UnsupportedRegistryAttributeError(message: str | None = None, *, attr_name: str, **kwargs)[source]

Bases: BaseRegistryError

An attribute was referenced that is not supported by the registry.

New in version 1.0.

message_template: ClassVar[_FormatStr] = '"%(attr_name)s" is not a registered lookup attribute.'[source]

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__init__(message: str | None = None, *, attr_name: str, **kwargs) None[source]

Initialize the error.

Parameters:
  • attr_name (str) – The name of the unsupported attribute that was used.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This support an %(attr_name)s format argument.

    If not provided, message_template will be used.

attr_name: str

The name of the unsupported attribute that was used.

exception registries.errors.BaseRegistryItemLookupError(message: str | None = None, *, attr_name: str, **kwargs)[source]

Bases: BaseRegistryError

Base class for errors in looking up an item from a registry.

New in version 1.0.

__init__(message: str | None = None, *, attr_name: str, **kwargs) None[source]

Initialize the error.

Parameters:
  • attr_name (str) – The name of the attribute that was used to look up the item.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This support an %(attr_name)s format argument.

    If not provided, message_template will be used.

attr_name: str

The name of the attribute that was used to look up the item.

exception registries.errors.ItemNotFoundLookupError(message: str | None = None, *, attr_name: str, attr_value: object)[source]

Bases: BaseRegistryItemLookupError

An item could not be found in the registry.

New in version 1.0.

message_template: ClassVar[_FormatStr] = 'No item registered with %(attr_name)s=%(attr_value)s.'[source]

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__init__(message: str | None = None, *, attr_name: str, attr_value: object) None[source]

Initialize the error.

Parameters:
  • attr_name (str) – The name of the attribute that was used to look up the item.

  • attr_value (object) – The attribute value used to look up the item.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This supports %(attr_name)s and %(attr_value)s format arguments.

    If not provided, message_template will be used.

attr_value: object

The attribute value used to look up the item.

exception registries.errors.BaseRegistrationError(message: str | None = None, *, item: RegistryItemType, **kwargs)[source]

Bases: Generic[RegistryItemType], BaseRegistryError

Base class for registration errors.

New in version 1.0.

__init__(message: str | None = None, *, item: RegistryItemType, **kwargs) None[source]

Initialize the error.

Parameters:
  • item (object) – The item that failed to be registered.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This supports an %(item)s format argument.

    If not provided, message_template will be used.

item: RegistryItemType

The item that failed to be registered.

__orig_bases__ = (typing.Generic[~RegistryItemType], <class 'registries.errors.BaseRegistryError'>)
__parameters__ = (~RegistryItemType,)
exception registries.errors.AlreadyRegisteredError(message: str | None = None, *, item: RegistryItemType, **kwargs)[source]

Bases: BaseRegistrationError[RegistryItemType]

The provided item is already registered.

New in version 1.0.

message_template: ClassVar[_FormatStr] = 'Could not register %(item)s: it is already registered.'[source]

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__orig_bases__ = (registries.errors.BaseRegistrationError[~RegistryItemType],)
__parameters__ = (~RegistryItemType,)
exception registries.errors.RegistrationConflictError(message: str | None = None, *, attr_name: str, attr_value: Any, item: RegistryItemType, other_item: RegistryItemType)[source]

Bases: BaseRegistrationError[RegistryItemType]

The provided item conflicts with an item that is already registered.

This may apply to a separate item matching the same lookup attributes.

New in version 1.0.

message_template: ClassVar[_FormatStr] = 'Could not register %(item)s: another item (%(other_item)s) is already registered with %(attr_name)s=%(attr_value)s.'[source]

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__init__(message: str | None = None, *, attr_name: str, attr_value: Any, item: RegistryItemType, other_item: RegistryItemType) None[source]

Initialize the error.

Parameters:
  • attr_name (str) – The name of the attribute that was used for registration.

  • attr_value (object) – The attribute value that conflicted.

  • item (object) – The item that failed to be registered.

  • other_item (object) – The conflicting item already in the registry.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This supports %(attr_name)s, %(attr_value)s, %(item)s, and %(other_item)s format arguments.

    If not provided, message_template will be used.

attr_name: str

The name of the attribute that was used for registration.

attr_value: object

The attribute value that conflicted.

other_item: RegistryItemType

The conflicting item already in the registry.

__orig_bases__ = (registries.errors.BaseRegistrationError[~RegistryItemType],)
__parameters__ = (~RegistryItemType,)
exception registries.errors.InvalidItemRegistrationError(message: str | None = None, *, attr_name: str, item: RegistryItemType)[source]

Bases: BaseRegistrationError[RegistryItemType]

An item could not be registered due to missing attributes.

New in version 1.0.

message_template: ClassVar[_FormatStr] = 'Could not register %(item)s: it does not have a "%(attr_name)s" attribute.'[source]

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__init__(message: str | None = None, *, attr_name: str, item: RegistryItemType) None[source]

Initialize the error.

Parameters:
  • attr_name (str) – The name of the attribute that was used for registration.

  • item (object) – The item that failed to be registered.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This supports %(attr_name)s and %(item)s format arguments.

    If not provided, message_template will be used.

attr_name: str

The name of the attribute that was used for registration.

__orig_bases__ = (registries.errors.BaseRegistrationError[~RegistryItemType],)
__parameters__ = (~RegistryItemType,)
exception registries.errors.BaseUnregistrationError(message: str | None = None, **kwargs)[source]

Bases: BaseRegistryError

Base class for unregistration errors.

New in version 1.0.

exception registries.errors.AttrNotFoundUnregistrationError(message: str | None = None, *, attr_name: str, attr_value: object)[source]

Bases: BaseUnregistrationError

An item was not found by attribute for unregistration.

New in version 1.0.

message_template: ClassVar[_FormatStr] = 'No item registered with %(attr_name)s=%(attr_value)s.'[source]

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__init__(message: str | None = None, *, attr_name: str, attr_value: object) None[source]

Initialize the error.

Parameters:
  • attr_name (str) – The name of the attribute that was used for unregistration.

  • attr_value (object) – The attribute value that was used for the lookup.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This supports %(attr_name)s and %(attr_value)s format arguments.

    If not provided, message_template will be used.

attr_name: str

The name of the attribute that was used for unregistration.

attr_value: object

The attribute value that was used for the lookup.

exception registries.errors.ItemNotFoundUnregistrationError(message: str | None = None, *, item: RegistryItemType)[source]

Bases: Generic[RegistryItemType], BaseUnregistrationError

An item was not found for unregistration.

New in version 1.0.

__orig_bases__ = (typing.Generic[~RegistryItemType], <class 'registries.errors.BaseUnregistrationError'>)
__parameters__ = (~RegistryItemType,)
message_template: ClassVar[_FormatStr] = 'Could not unregister %(item)s: it is not registered.'[source]

The template for an error message.

This is in the form of a %-based format string. Subclasses can provide custom error messages for specific error types or custom registries.

__init__(message: str | None = None, *, item: RegistryItemType) None[source]

Initialize the error.

Parameters:
  • item (object) – The item that failed to be unregistered.

  • message (str, optional) –

    An explicit error message as a %-based format string.

    This supports an %(item)s format argument.

    If not provided, message_template will be used.

item: RegistryItemType

The item that failed to be registered.