Skip to content

SubConfig

Bases: ConfigObject

Base for nested configuration sections. When used as a type of properties on ConfigObject classes or its children, can then automatically be converted from mappings on initialization.

Examples:

Creation of a sub-config class:

class BotConfig(SubConfig):
    api_token: str

Using sub-configs inside a custom config:

class CustomConfig(ConfigObject):
    bot: BotConfig

from_dict(data) classmethod

Create a config object from dict (or any other dict-compatible mapping).

Parameters:

Name Type Description Default
data Mapping[str, Any]

The data mapping to create a config object from.

required

Returns:

Name Type Description
ConfigObject Self

The config object created from data mapping.