register_config#
- register_config(type_hint: str, plugin: str | None = None, upgrader: collections.abc.Callable[[dict, int], dict] | None = None) Callable[[], Config][source]#
Class decorator used to register Config classes with registry.
All Configs must be registered! Registering a Config does the following:
Associates Config classes with type_hint, plugin, and upgrader, which is necessary for polymorphic deserialization. See build_config() for more details.
Adds a constant type_hint field to the Config which is set to type_hint.
- Parameters:
type_hint (str) – a type hint used to deserialize Configs. Must be unique across all registered Configs.
plugin (str | None) – the module path of the plugin where the
Configis defined. IfNone, will be inferred. Defauilts toNone.upgrader (collections.abc.Callable[[dict, int], dict] | None) – a function of the form
upgrade(config_dict, version)which returns the corresponding config dict ofversion = version + 1. This can be useful for maintaining backward compatibility by allowing old configs using an outdated schema to be upgraded to the current schema. Defaults toNone.
- Returns:
A function that returns a new class that is identical to the input
Configwith an additionaltype_hintfield.- Return type: