config
Config
Base class for storing a collection of configurations.
Subclasses may store a class attribute, _config
, with the current global configurations, which can be retrieved or updated by the user.
Source code in fancy_dataclass/config.py
as_config()
Context manager which temporarily updates the global configuration with this object.
Source code in fancy_dataclass/config.py
clear_config()
classmethod
get_config()
classmethod
Gets a copy of the current global configuration.
Returns:
Type | Description |
---|---|
Optional[Self]
|
Global configuration object ( |
Source code in fancy_dataclass/config.py
ConfigDataclass
Bases: DictDataclass
, FileConfig
A dataclass representing a collection of configurations.
The configurations can be loaded from a file, the type of which will be inferred from its extension. Supported file types are:
- JSON
- TOML
Source code in fancy_dataclass/config.py
DictConfig
Bases: Config
, Dict[Any, Any]
A collection of configurations, stored as a Python dict.
To impose a type schema on the configurations, use ConfigDataclass
instead.
The configurations can be loaded from a file, the type of which will be inferred from its extension. Supported file types are:
- JSON
- TOML
Source code in fancy_dataclass/config.py
FileConfig
Bases: Config
, ABC
A collection of configurations that can be loaded from a file.
Source code in fancy_dataclass/config.py
load_config(path)
abstractmethod
classmethod
Loads configurations from a file and sets them to be the global configurations for this class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
AnyPath
|
File from which to load configurations |
required |
Returns:
Type | Description |
---|---|
Self
|
The newly loaded global configurations |